#include <cstdio> #include <algorithm> using namespace std; int in[100001]; int out[100001]; int test() { int n, m; scanf("%i%i", &n, &m); fill(in, in+n+1, 0); fill(out, out+n+1, 0); int maxin = 0, emptyout = n; for(int i = 0; i < m; i++) { int a, b; char c; scanf("%i %c %i", &a, &c, &b); if(c == '>') { in[b]++; maxin = max(maxin, in[b]); } else { out[b]++; emptyout -= (out[b] == 1); } } if(maxin == n) return 1; if(emptyout > 0) return 0; return -1; } int main() { int t; scanf("%i", &t); while(t--) { int w = test(); if(w == -1) printf("PRZEGRANA\n"); if(w == 0) printf("REMIS\n"); if(w == 1) printf("WYGRANA\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 44 45 | #include <cstdio> #include <algorithm> using namespace std; int in[100001]; int out[100001]; int test() { int n, m; scanf("%i%i", &n, &m); fill(in, in+n+1, 0); fill(out, out+n+1, 0); int maxin = 0, emptyout = n; for(int i = 0; i < m; i++) { int a, b; char c; scanf("%i %c %i", &a, &c, &b); if(c == '>') { in[b]++; maxin = max(maxin, in[b]); } else { out[b]++; emptyout -= (out[b] == 1); } } if(maxin == n) return 1; if(emptyout > 0) return 0; return -1; } int main() { int t; scanf("%i", &t); while(t--) { int w = test(); if(w == -1) printf("PRZEGRANA\n"); if(w == 0) printf("REMIS\n"); if(w == 1) printf("WYGRANA\n"); } } |