#include <memory.h> #include<iostream> enum { N = 1000000, M = 2000000, T = 20 }; int aloses[N+1], bloses[N+1]; int main() { int t; std::cin >> t; while (t--) { int n,m; std::cin >> n >> m; ::bzero(aloses, (1+n) * sizeof(aloses[0])); ::bzero(bloses, (1+n) * sizeof(aloses[0])); while (m--) { int a,b; char w; std::cin >> a >> w >> b; if (w == '>') { bloses[b]++; } else { aloses[a]++; } } for (int i = 1; i <= n; i++) { if (bloses[i] == n) std::cout << "WYGRANA\n"; else if (aloses[i] == n) std::cout << "PRZEGRANA\n"; else continue; n = 0; break; } if (n) std::cout << "REMIS\n"; } }
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 | #include <memory.h> #include<iostream> enum { N = 1000000, M = 2000000, T = 20 }; int aloses[N+1], bloses[N+1]; int main() { int t; std::cin >> t; while (t--) { int n,m; std::cin >> n >> m; ::bzero(aloses, (1+n) * sizeof(aloses[0])); ::bzero(bloses, (1+n) * sizeof(aloses[0])); while (m--) { int a,b; char w; std::cin >> a >> w >> b; if (w == '>') { bloses[b]++; } else { aloses[a]++; } } for (int i = 1; i <= n; i++) { if (bloses[i] == n) std::cout << "WYGRANA\n"; else if (aloses[i] == n) std::cout << "PRZEGRANA\n"; else continue; n = 0; break; } if (n) std::cout << "REMIS\n"; } } |