// Author: Krzysztof Bochenek
// Email: kpbochenek@gmail.com
// --------------------------------
#include <stdio.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;
string win = "WYGRANA";
string loss = "PRZEGRANA";
string draw = "REMIS";
const int NSIZE = 200000;
bool A[NSIZE], B[NSIZE];
int C[NSIZE];
int main() {
int t, n, m;
int a, b;
char w;
cin >> t;
while (t --> 0) {
cin >> n >> m;
for (int i=0; i<n; ++i) {
A[i] = B[i] = false;
}
for (int i=0; i<m; ++i) {
cin >> a >> w >> b;
if (w == '>') {
A[a-1] = true;
C[b-1]++;
} else {
B[b-1] = true;
}
}
bool AR = true, BR = true;
bool double_attack = false;
for (int i=0; i<n; ++i) {
AR = AR && A[i];
double_attack = double_attack || (C[i] > 1);
BR = BR && B[i];
}
if (BR) {
cout << loss << endl;
} else if (AR && double_attack) {
cout << win << endl;
} else {
cout << draw << endl;
}
}
return 0;
}
/*
(przeciwnik zaczyna)
Teoria: Jeżeli atakuję wszystkimi, to wygrywam.
Jeżeli nie atakuję wszystkimi, to nie mogę wygrać.
Chcę w takim razie remis!
Jeżeli każdy przeciwnik mnie atakuje, to nie mam szans,
w przeciwnym razie zostawię tylko tego nie atakującego i remis
*/
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 73 74 75 76 77 78 79 80 81 | // Author: Krzysztof Bochenek // Email: kpbochenek@gmail.com // -------------------------------- #include <stdio.h> #include <vector> #include <map> #include <set> #include <stack> #include <math.h> #include <algorithm> #include <string> #include <iostream> typedef long long int ll; typedef unsigned long long ull; using namespace std; string win = "WYGRANA"; string loss = "PRZEGRANA"; string draw = "REMIS"; const int NSIZE = 200000; bool A[NSIZE], B[NSIZE]; int C[NSIZE]; int main() { int t, n, m; int a, b; char w; cin >> t; while (t --> 0) { cin >> n >> m; for (int i=0; i<n; ++i) { A[i] = B[i] = false; } for (int i=0; i<m; ++i) { cin >> a >> w >> b; if (w == '>') { A[a-1] = true; C[b-1]++; } else { B[b-1] = true; } } bool AR = true, BR = true; bool double_attack = false; for (int i=0; i<n; ++i) { AR = AR && A[i]; double_attack = double_attack || (C[i] > 1); BR = BR && B[i]; } if (BR) { cout << loss << endl; } else if (AR && double_attack) { cout << win << endl; } else { cout << draw << endl; } } return 0; } /* (przeciwnik zaczyna) Teoria: Jeżeli atakuję wszystkimi, to wygrywam. Jeżeli nie atakuję wszystkimi, to nie mogę wygrać. Chcę w takim razie remis! Jeżeli każdy przeciwnik mnie atakuje, to nie mam szans, w przeciwnym razie zostawię tylko tego nie atakującego i remis */ |
English