#include <cstdio> #define MAX_N 100000 using namespace std; int firstCount[MAX_N + 1], secondCount[MAX_N + 1]; void test() { int n, m, a, b; char w; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { firstCount[i] = 0; secondCount[i] = 0; } for (int i = 0; i < m; i++) { scanf("%d %c %d", &a, &w, &b); if (w == '>') { firstCount[b]++; } else { secondCount[b]++; } } for (int i = 1; i <= n; i++) { if (firstCount[i] == n) { puts("WYGRANA"); return; } } for (int i = 1; i <= n; i++) { if (secondCount[i] == 0) { puts("REMIS"); return; } } puts("PRZEGRANA"); } int main() { int t; #ifdef _PA_USE_TEST_INPUT_FILE_ freopen("input2.txt","rt",stdin); #endif scanf("%d", &t); for (int i = 0; i < t; i++) { test(); } 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 | #include <cstdio> #define MAX_N 100000 using namespace std; int firstCount[MAX_N + 1], secondCount[MAX_N + 1]; void test() { int n, m, a, b; char w; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { firstCount[i] = 0; secondCount[i] = 0; } for (int i = 0; i < m; i++) { scanf("%d %c %d", &a, &w, &b); if (w == '>') { firstCount[b]++; } else { secondCount[b]++; } } for (int i = 1; i <= n; i++) { if (firstCount[i] == n) { puts("WYGRANA"); return; } } for (int i = 1; i <= n; i++) { if (secondCount[i] == 0) { puts("REMIS"); return; } } puts("PRZEGRANA"); } int main() { int t; #ifdef _PA_USE_TEST_INPUT_FILE_ freopen("input2.txt","rt",stdin); #endif scanf("%d", &t); for (int i = 0; i < t; i++) { test(); } return 0; } |