#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
int wynik [20];
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int t, n, m;
int ha, hb;
char hw;
//vector <int> a;
set <int> sa;
set <int>::iterator it;
cin>>t;
for(int j=0; j<t; j++)
{
sa.clear();
//a.clear();
cin>>n>>m;
for(int i=0; i<m; i++) //wczytanie
{
cin>>ha>>hw>>hb;
if(hw=='<') // przegrana
{
wynik[j]=3;
}
//a.push_back(ha);
sa.insert(ha);
}
if(wynik[j]!=0) continue;
if(n>m || n>sa.size()) //remis
{
wynik[j]=2;
continue;
}
//sort(a.begin(), a.end());
int k=1;
for(it=sa.begin(); it!=sa.end(); it++, k++)
{
if(*it!=k)
{
wynik[j]=2; //remis
goto flaga;
}
}
wynik[j]=1;
flaga:;
}
for(int i=0; i<t; i++)
{
if(wynik[i]==1)
cout<<"WYGRANA"<<endl;
else if(wynik[i]==2)
cout<<"REMIS"<<endl;
else if(wynik[i]==3)
cout<<"PRZEGRANA"<<endl;
}
}
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 | #include <iostream> #include <vector> #include <algorithm> #include <set> int wynik [20]; using namespace std; int main() { ios::sync_with_stdio(false); int t, n, m; int ha, hb; char hw; //vector <int> a; set <int> sa; set <int>::iterator it; cin>>t; for(int j=0; j<t; j++) { sa.clear(); //a.clear(); cin>>n>>m; for(int i=0; i<m; i++) //wczytanie { cin>>ha>>hw>>hb; if(hw=='<') // przegrana { wynik[j]=3; } //a.push_back(ha); sa.insert(ha); } if(wynik[j]!=0) continue; if(n>m || n>sa.size()) //remis { wynik[j]=2; continue; } //sort(a.begin(), a.end()); int k=1; for(it=sa.begin(); it!=sa.end(); it++, k++) { if(*it!=k) { wynik[j]=2; //remis goto flaga; } } wynik[j]=1; flaga:; } for(int i=0; i<t; i++) { if(wynik[i]==1) cout<<"WYGRANA"<<endl; else if(wynik[i]==2) cout<<"REMIS"<<endl; else if(wynik[i]==3) cout<<"PRZEGRANA"<<endl; } } |
English