#include<iostream>
#include<vector>
using namespace std;
int test(){
int n,m;
cin>>n>>m;
vector<int> Win (n,0);
vector<int> Lose (n,0);
while(m-->0){
int a,b;
char w;
cin>>a>>w>>b;
if(w=='>'){
Lose[b-1]++;
}
if(w=='<'){
Win[b-1]++;
}
}
int a=0;
for(int i = 0; i < n; i++){
if(Win[i]) a++;
}
if(a==n) return -1;
for(int i = 0; i < n; i++){
if(Lose[i]==n) return 1;
}
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tau;
cin>>tau;
while(tau-->0){
int wyn=test();
if(wyn==1){cout<<"WYGRANA"<<'\n';}
if(wyn==0){cout<<"REMIS"<<'\n';}
if(wyn==-1){cout<<"PRZEGRANA"<<'\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 | #include<iostream> #include<vector> using namespace std; int test(){ int n,m; cin>>n>>m; vector<int> Win (n,0); vector<int> Lose (n,0); while(m-->0){ int a,b; char w; cin>>a>>w>>b; if(w=='>'){ Lose[b-1]++; } if(w=='<'){ Win[b-1]++; } } int a=0; for(int i = 0; i < n; i++){ if(Win[i]) a++; } if(a==n) return -1; for(int i = 0; i < n; i++){ if(Lose[i]==n) return 1; } return 0; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int tau; cin>>tau; while(tau-->0){ int wyn=test(); if(wyn==1){cout<<"WYGRANA"<<'\n';} if(wyn==0){cout<<"REMIS"<<'\n';} if(wyn==-1){cout<<"PRZEGRANA"<<'\n';} } return 0; } |
English