#include <cstdio> #include <algorithm> int main() { int t, n, m, a, b; char dir[1000]; int MAXN = 100010; int bDegMap[MAXN]; int bDegSet[MAXN]; for(scanf("%d", &t); t; t--) { scanf("%d%d", &n, &m); std::fill(bDegMap, bDegMap + n + 5, 0); std::fill(bDegSet, bDegSet + n + 5, 0); bool aWins = false; bool bWins = false; int noOfNon0Bs = 0; for(int i = 0; i < m; i++) { scanf("%d%s%d", &a, dir, &b); if(dir[0] == '>') { bDegMap[b]++; if(bDegMap[b] == n) { aWins = true; } } else { if(bDegSet[b] == 0) { bDegSet[b]++; noOfNon0Bs++; } } } if(noOfNon0Bs == n) { bWins = true; } if(aWins) { printf("WYGRANA\n"); } else if(bWins) { printf("PRZEGRANA\n"); } else { printf("REMIS\n"); } } 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 | #include <cstdio> #include <algorithm> int main() { int t, n, m, a, b; char dir[1000]; int MAXN = 100010; int bDegMap[MAXN]; int bDegSet[MAXN]; for(scanf("%d", &t); t; t--) { scanf("%d%d", &n, &m); std::fill(bDegMap, bDegMap + n + 5, 0); std::fill(bDegSet, bDegSet + n + 5, 0); bool aWins = false; bool bWins = false; int noOfNon0Bs = 0; for(int i = 0; i < m; i++) { scanf("%d%s%d", &a, dir, &b); if(dir[0] == '>') { bDegMap[b]++; if(bDegMap[b] == n) { aWins = true; } } else { if(bDegSet[b] == 0) { bDegSet[b]++; noOfNon0Bs++; } } } if(noOfNon0Bs == n) { bWins = true; } if(aWins) { printf("WYGRANA\n"); } else if(bWins) { printf("PRZEGRANA\n"); } else { printf("REMIS\n"); } } return 0; } |