#include <bits/stdc++.h> using namespace std; #define pb push_back const int N = 1e5 + 7; int n, m; int deg[N]; bool vis[N]; bool i_win(){ for(int i = 1; i <= n; ++i) if(deg[i] == n) return true; return false; } bool he_win(){ for(int i = 1; i <= n; ++i) if(!vis[i]) return false; return true; } void solve(){ scanf("%d %d", &n, &m); for(int i = 0; i < m; ++i){ int a, b; char s[2]; scanf("%d %s %d", &a, s, &b); if(s[0] == '<') vis[b] = true; else deg[b]++; } if(i_win()){ puts("WYGRANA"); return; } if(he_win()){ puts("PRZEGRANA"); return; } puts("REMIS"); } void clear(){ for(int i = 1; i <= n; ++i){ vis[i] = false; deg[i] = 0; } } int main(){ int quest; scanf("%d", &quest); while(quest--){ solve(); clear(); } 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 | #include <bits/stdc++.h> using namespace std; #define pb push_back const int N = 1e5 + 7; int n, m; int deg[N]; bool vis[N]; bool i_win(){ for(int i = 1; i <= n; ++i) if(deg[i] == n) return true; return false; } bool he_win(){ for(int i = 1; i <= n; ++i) if(!vis[i]) return false; return true; } void solve(){ scanf("%d %d", &n, &m); for(int i = 0; i < m; ++i){ int a, b; char s[2]; scanf("%d %s %d", &a, s, &b); if(s[0] == '<') vis[b] = true; else deg[b]++; } if(i_win()){ puts("WYGRANA"); return; } if(he_win()){ puts("PRZEGRANA"); return; } puts("REMIS"); } void clear(){ for(int i = 1; i <= n; ++i){ vis[i] = false; deg[i] = 0; } } int main(){ int quest; scanf("%d", &quest); while(quest--){ solve(); clear(); } return 0; } |