#include<algorithm> #include<cassert> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define FORD(i,a,b) for(int i=(a);i>=(b);i--) #define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i) void doit() { int m, n; scanf("%d %d", &n, &m); VI lose(n, false); // If all true, I lose. VI win(n, 0); // If one =n, I win. REP(i, m) { int a, b; char c; scanf("%d %c %d", &a, &c, &b); --a; --b; if (c == '<') { lose[b] = true; } else if (c == '>') { win[b]++; } else { cerr << "ERROR"; exit(1); } } bool do_lose = true; REP(i, n) { if (!lose[i]) { do_lose = false; break; } } if (do_lose) { cout << "PRZEGRANA" << endl; return; } REP(i, n) { if (win[i] == n) { cout << "WYGRANA" << endl; return; } } cout << "REMIS" << endl; return; } int main() { int T; scanf("%d", &T); while (T--) doit(); return 0; }
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #include<algorithm> #include<cassert> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define FORD(i,a,b) for(int i=(a);i>=(b);i--) #define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i) void doit() { int m, n; scanf("%d %d", &n, &m); VI lose(n, false); // If all true, I lose. VI win(n, 0); // If one =n, I win. REP(i, m) { int a, b; char c; scanf("%d %c %d", &a, &c, &b); --a; --b; if (c == '<') { lose[b] = true; } else if (c == '>') { win[b]++; } else { cerr << "ERROR"; exit(1); } } bool do_lose = true; REP(i, n) { if (!lose[i]) { do_lose = false; break; } } if (do_lose) { cout << "PRZEGRANA" << endl; return; } REP(i, n) { if (win[i] == n) { cout << "WYGRANA" << endl; return; } } cout << "REMIS" << endl; return; } int main() { int T; scanf("%d", &T); while (T--) doit(); return 0; } |