#include<cstdio>
#include<algorithm>
const int N=100001;
int degBaj[N];
int degBit[N];
int main() {
int t,n,m,a,b; char c;
scanf("%d",&t);
for(int i=0; i<t; ++i) {
scanf("%d%d",&n,&m);
std::fill(degBaj,degBaj+n+1,0);
std::fill(degBit,degBit+n+1,0);
for(int j=0; j<m; ++j) {
scanf("%d %c %d",&a,&c,&b);
if(c=='<') degBit[b]++;
else degBaj[b]++;
}
bool won=false,lost=true;
for(int j=1; j<n+1; ++j) {
if(degBaj[j]==n) won=true;
if(degBit[j]==0) lost=false;
}
if(won) printf("WYGRANA\n");
else {
if(lost) 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 | #include<cstdio> #include<algorithm> const int N=100001; int degBaj[N]; int degBit[N]; int main() { int t,n,m,a,b; char c; scanf("%d",&t); for(int i=0; i<t; ++i) { scanf("%d%d",&n,&m); std::fill(degBaj,degBaj+n+1,0); std::fill(degBit,degBit+n+1,0); for(int j=0; j<m; ++j) { scanf("%d %c %d",&a,&c,&b); if(c=='<') degBit[b]++; else degBaj[b]++; } bool won=false,lost=true; for(int j=1; j<n+1; ++j) { if(degBaj[j]==n) won=true; if(degBit[j]==0) lost=false; } if(won) printf("WYGRANA\n"); else { if(lost) printf("PRZEGRANA\n"); else printf("REMIS\n"); } } return 0; } |
English