#include <bits/stdc++.h>
using namespace std;
int wejscie2[100007];
bool wyjscie2[100007];
bool wych1[100007];
int main() {
ios_base::sync_with_stdio(0);
int testy; cin >> testy;
while(testy--)
{
int n, m; cin >> n >> m;
memset(wejscie2, 0, 100007);
memset(wyjscie2, 0, 100007);
memset(wych1, 0, 100007);
int A = 0, B = 0, liczek = 0, liczeg = 0;
for(int i = 1; i <= m; ++i)
{
int x, y; char c;
cin >> x >> c >> y;
if(c == '>'){
if(wych1[x] == 0){
++A;
wych1[x] = 1;
}
++wejscie2[y];
}
else
wyjscie2[y] = 1;
}
bool calosc = 0;
for(int i = 1; i <= n; ++i){
liczeg += wyjscie2[i];
if(wejscie2[i] >= n)
calosc = 1;
}
if(A == n && calosc)
cout << "WYGRANA" << endl;
else if(liczeg == n)
cout << "PRZEGRANA" << endl;
else
cout << "REMIS" << endl;
//cout << n << " " << m << " " << A << endl;
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #include <bits/stdc++.h> using namespace std; int wejscie2[100007]; bool wyjscie2[100007]; bool wych1[100007]; int main() { ios_base::sync_with_stdio(0); int testy; cin >> testy; while(testy--) { int n, m; cin >> n >> m; memset(wejscie2, 0, 100007); memset(wyjscie2, 0, 100007); memset(wych1, 0, 100007); int A = 0, B = 0, liczek = 0, liczeg = 0; for(int i = 1; i <= m; ++i) { int x, y; char c; cin >> x >> c >> y; if(c == '>'){ if(wych1[x] == 0){ ++A; wych1[x] = 1; } ++wejscie2[y]; } else wyjscie2[y] = 1; } bool calosc = 0; for(int i = 1; i <= n; ++i){ liczeg += wyjscie2[i]; if(wejscie2[i] >= n) calosc = 1; } if(A == n && calosc) cout << "WYGRANA" << endl; else if(liczeg == n) cout << "PRZEGRANA" << endl; else cout << "REMIS" << endl; //cout << n << " " << m << " " << A << endl; } } |
English