#include <cstdio> const int maxN = 1e5 + 10; int din[maxN], dout[maxN]; struct Cleaner { int n; Cleaner(int n) : n(n) {} ~Cleaner() { for(int i = 0; i <= n; ++i) din[i] = dout[i] = 0; } }; void prog() { int n, m; scanf("%d%d", &n, &m); Cleaner c(n); char w[10]; for(int a, b, i = 0; i < m; ++i) { scanf("%d%s%d", &a, w, &b); if(w[0] == '<') dout[b]++; else din[b]++; } for(int i = 1; i <= n; ++i) if(din[i] == n) { printf("WYGRANA\n"); return; } for(int i = 1; i <= n; ++i) if(dout[i] == 0) { printf("REMIS\n"); return; } printf("PRZEGRANA\n"); } int main() { int t; scanf("%d", &t); while(t--) prog(); }
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 | #include <cstdio> const int maxN = 1e5 + 10; int din[maxN], dout[maxN]; struct Cleaner { int n; Cleaner(int n) : n(n) {} ~Cleaner() { for(int i = 0; i <= n; ++i) din[i] = dout[i] = 0; } }; void prog() { int n, m; scanf("%d%d", &n, &m); Cleaner c(n); char w[10]; for(int a, b, i = 0; i < m; ++i) { scanf("%d%s%d", &a, w, &b); if(w[0] == '<') dout[b]++; else din[b]++; } for(int i = 1; i <= n; ++i) if(din[i] == n) { printf("WYGRANA\n"); return; } for(int i = 1; i <= n; ++i) if(dout[i] == 0) { printf("REMIS\n"); return; } printf("PRZEGRANA\n"); } int main() { int t; scanf("%d", &t); while(t--) prog(); } |