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
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

int main() {

    ios::sync_with_stdio(false);
    unsigned int t, n, m, i, j, a, b;
    char op;

    cin >> t;

    for (i = 0; i < t; ++i) {
        cin >> n;
        cin >> m;

        unsigned int bajtArr[n];
        unsigned int bitArr[n];
        unsigned int bajtArrMax = 0;
        unsigned int bitArrMax = 0;
        std::unordered_set<int> bitSet;

        for (j = 0; j < n; ++j) {
            bajtArr[j] = 0;
            bitArr[j] = 0;
        }

        for (j = 0; j < m; ++j) {
            cin >> a;
            cin >> op;
            cin >> b;

            if ('>' == op) {
                bajtArr[b - 1] += 1;
                if (bajtArr[b - 1] > bajtArrMax) {
                    bajtArrMax = bajtArr[b - 1];
                }
            } else {
                bitArr[a - 1] += 1;
                if (bitArr[a - 1] > bitArrMax) {
                    bitArrMax = bitArr[a - 1];
                }
                bitSet.insert(b);
            }
        }

        if (bajtArrMax >= n) {
            cout << "WYGRANA" << endl;
        } else if (bitArrMax >= n || bitSet.size() >= n) {
            cout << "PRZEGRANA" << endl;
        } else {
            cout << "REMIS" << endl;
        }
    }
    return 0;
}