#include <iostream> #define MAXM 200001 #define MAXN 100001 using namespace std; int g1[MAXN], g2[MAXN]; int main () { int t, n, m, i, j, a, b, min1, min2; char c; cin >> t; while (t--) { cin >> n >> m; for (i=1; i<=n; i++) { g1[i] = g2[i] = 0; } for (i=1; i<=m; i++) { cin >> a >> c >> b; if (c=='>') { g1[a]++; } else { g2[b]++; } } min1 = g1[1]; min2 = g2[1]; for (i=1; i<=n; i++) { min1=(g1[i]<min1)?g1[i]:min1; min2=(g2[i]<min2)?g2[i]:min2; } if (min1>min2) cout << "WYGRANA"; else if (min1<min2) cout << "PRZEGRANA"; else cout << "REMIS"; cout << endl; } 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 | #include <iostream> #define MAXM 200001 #define MAXN 100001 using namespace std; int g1[MAXN], g2[MAXN]; int main () { int t, n, m, i, j, a, b, min1, min2; char c; cin >> t; while (t--) { cin >> n >> m; for (i=1; i<=n; i++) { g1[i] = g2[i] = 0; } for (i=1; i<=m; i++) { cin >> a >> c >> b; if (c=='>') { g1[a]++; } else { g2[b]++; } } min1 = g1[1]; min2 = g2[1]; for (i=1; i<=n; i++) { min1=(g1[i]<min1)?g1[i]:min1; min2=(g2[i]<min2)?g2[i]:min2; } if (min1>min2) cout << "WYGRANA"; else if (min1<min2) cout << "PRZEGRANA"; else cout << "REMIS"; cout << endl; } return 0; } |