#include <iostream>
//#include <vector>
//#include <algorithm>
using namespace std;
int Bajtek[100010];
int Bitek[100010];
//vector <int> bitki[100010];
bool posortowane[100010];
//vector<int>::iterator it;
//vector <int> wektorek;
int koniec;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    for(int i=0; i < t; ++i)
    {
        int n, m, a, b, stan=-1;
        char c;
        cin >> n >> m;
        koniec = 0;
        for(int j=0; j<=n; ++j)
        {
            Bajtek[j] = 0;
            Bitek[j] = 0;
            //bitki[j].clear();
            posortowane[j] = 0;
        }
        for(int j=0; j<m;++j)
        {
            cin >> a >> c >> b;
            if(c=='>'){++Bajtek[b]; if(Bajtek[b]==n){stan=1;}}
            else if(c=='<'){++Bitek[a];if(!posortowane[b]){++koniec;} posortowane[b]=1;}
        }
        /*for(int j=0; j <= n; ++j)
        {
            if(!posortowane[j]) {sort(bitki[j].begin(), bitki[j].end()); posortowane[j]=1;}
            if(bitki[j].size() ==0 || koniec){continue;}
            for(int k = j+1; k <=n; ++k)
            {
                if(bitki[k].size()==0){break;}
                if(bitki[j].size() + bitki[k].size() >= n)
                {
                   if(!posortowane[k]){sort(bitki[k].begin(), bitki[k].end()); posortowane[k]=1;}
                   wektorek.clear();
                   wektorek.resize(n+10);
                   it = set_union(bitki[j].begin(), bitki[j].end(), bitki[k].begin(), bitki[k].end(), wektorek.begin());
                   if(it - wektorek.begin() == n){/*cout << "\n" << i <<" " << it - wektorek.begin() << "\n";stan = 0; koniec = true; break;}
                }
            }
        }*/
        if(stan!=1 && koniec == n){stan=0;}
        switch(stan)
        {
            case -1: puts("REMIS");
            break;
            case 0: puts("PRZEGRANA");
            break;
            case 1: puts("WYGRANA");
        }
    }
}
        | 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 63 64 65 66 67 68 69 70 71 72 | #include <iostream> //#include <vector> //#include <algorithm> using namespace std; int Bajtek[100010]; int Bitek[100010]; //vector <int> bitki[100010]; bool posortowane[100010]; //vector<int>::iterator it; //vector <int> wektorek; int koniec; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; for(int i=0; i < t; ++i) { int n, m, a, b, stan=-1; char c; cin >> n >> m; koniec = 0; for(int j=0; j<=n; ++j) { Bajtek[j] = 0; Bitek[j] = 0; //bitki[j].clear(); posortowane[j] = 0; } for(int j=0; j<m;++j) { cin >> a >> c >> b; if(c=='>'){++Bajtek[b]; if(Bajtek[b]==n){stan=1;}} else if(c=='<'){++Bitek[a];if(!posortowane[b]){++koniec;} posortowane[b]=1;} } /*for(int j=0; j <= n; ++j) { if(!posortowane[j]) {sort(bitki[j].begin(), bitki[j].end()); posortowane[j]=1;} if(bitki[j].size() ==0 || koniec){continue;} for(int k = j+1; k <=n; ++k) { if(bitki[k].size()==0){break;} if(bitki[j].size() + bitki[k].size() >= n) { if(!posortowane[k]){sort(bitki[k].begin(), bitki[k].end()); posortowane[k]=1;} wektorek.clear(); wektorek.resize(n+10); it = set_union(bitki[j].begin(), bitki[j].end(), bitki[k].begin(), bitki[k].end(), wektorek.begin()); if(it - wektorek.begin() == n){/*cout << "\n" << i <<" " << it - wektorek.begin() << "\n";stan = 0; koniec = true; break;} } } }*/ if(stan!=1 && koniec == n){stan=0;} switch(stan) { case -1: puts("REMIS"); break; case 0: puts("PRZEGRANA"); break; case 1: puts("WYGRANA"); } } } | 
 
            
         English
                    English