#include<bits/stdc++.h> #include<cstdio> using namespace std; #define R(p, k) for(int i = p; i <= k; i++) #define RI(i, p, k) for(int i = p; i <= k; i++) #define IR(k, p) for(int i = k; i >= p; i--) #define IRI(i, p, k) for(int i = k; i >= p; i--) #define DEB 0 #if DEB #define EPRLL(a) fprintf(stderr, "%s %lld ", #a, a); #define EPRN fprintf(stderr, "\n"); #else #define EPRLL(a) #define EPRN #endif const int MN=1e5+5; int n, m, t, indeg[MN], outdeg[MN]; int main(){ int a, b; char s[5]; scanf("%d", &t); RI(j, 0, t-1){ scanf("%d%d", &n, &m); R(1, n){ indeg[i]=0; outdeg[i]=0; } R(0, m-1){ scanf("%d%s%d", &a, s, &b); if(s[0]=='<') outdeg[b]++; else indeg[b]++; } bool isloser = false, allwin = true; R(1, n){ if(indeg[i]==n) isloser = true; if(outdeg[i]==0) allwin = false; } if(isloser) printf("WYGRANA\n"); else if(allwin) 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #include<bits/stdc++.h> #include<cstdio> using namespace std; #define R(p, k) for(int i = p; i <= k; i++) #define RI(i, p, k) for(int i = p; i <= k; i++) #define IR(k, p) for(int i = k; i >= p; i--) #define IRI(i, p, k) for(int i = k; i >= p; i--) #define DEB 0 #if DEB #define EPRLL(a) fprintf(stderr, "%s %lld ", #a, a); #define EPRN fprintf(stderr, "\n"); #else #define EPRLL(a) #define EPRN #endif const int MN=1e5+5; int n, m, t, indeg[MN], outdeg[MN]; int main(){ int a, b; char s[5]; scanf("%d", &t); RI(j, 0, t-1){ scanf("%d%d", &n, &m); R(1, n){ indeg[i]=0; outdeg[i]=0; } R(0, m-1){ scanf("%d%s%d", &a, s, &b); if(s[0]=='<') outdeg[b]++; else indeg[b]++; } bool isloser = false, allwin = true; R(1, n){ if(indeg[i]==n) isloser = true; if(outdeg[i]==0) allwin = false; } if(isloser) printf("WYGRANA\n"); else if(allwin) printf("PRZEGRANA\n"); else printf("REMIS\n"); } return 0; } |