#include<iostream> using namespace std; const int MAX_N = 100010; int lefty[MAX_N]; bool righty[MAX_N]; int main() { ios_base::sync_with_stdio(0); int t; cin >> t; for (int i = 0; i < MAX_N; i++) { lefty[i] = 0; righty[i] = false; } int a, b; char c; int n, m; bool some_flag; for (int q = 0; q < t; q++) { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> c >> b; if (c == '>') { ++lefty[b - 1]; } else { righty[b - 1] = true; } } some_flag = false; for (int i = 0; i < n; i++) { if (lefty[i] == n) { some_flag = true; } } if (some_flag) { cout << "WYGRANA\n"; } else { some_flag = true; for (int i = 0; i < n; i++) { if (!righty[i]) { some_flag = false; } } if (some_flag) { cout << "PRZEGRANA\n"; } else { cout << "REMIS\n"; } } for (int i = 0; i < n; i++) { lefty[i] = 0; righty[i] = false; } } 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 71 72 73 | #include<iostream> using namespace std; const int MAX_N = 100010; int lefty[MAX_N]; bool righty[MAX_N]; int main() { ios_base::sync_with_stdio(0); int t; cin >> t; for (int i = 0; i < MAX_N; i++) { lefty[i] = 0; righty[i] = false; } int a, b; char c; int n, m; bool some_flag; for (int q = 0; q < t; q++) { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> c >> b; if (c == '>') { ++lefty[b - 1]; } else { righty[b - 1] = true; } } some_flag = false; for (int i = 0; i < n; i++) { if (lefty[i] == n) { some_flag = true; } } if (some_flag) { cout << "WYGRANA\n"; } else { some_flag = true; for (int i = 0; i < n; i++) { if (!righty[i]) { some_flag = false; } } if (some_flag) { cout << "PRZEGRANA\n"; } else { cout << "REMIS\n"; } } for (int i = 0; i < n; i++) { lefty[i] = 0; righty[i] = false; } } return 0; } |