#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
void add(int& liczba, vector<int>& v, int index) {
if (v[index] == 0)
liczba++;
v[index]++;
}
int ileRozlacznych(const vector< vector<int> >& ktoGoAtakuje, int n) {
vector<int> maPare(n+1);
for (int i = 1; i <= n; ++i)
maPare[i] = 0;
for (int i = 1; i <= n; ++i) {
const vector<int>& atakujacy = ktoGoAtakuje[i];
if (atakujacy.size() > 1) {
for (int at: atakujacy)
maPare[at] = 1;
}
}
int sum = 0;
for (int i = 1; i <= n; ++i)
sum += maPare[i];
return n - sum;
}
void testCase() {
//cerr << "------------- START TEST CASE -------------------" << endl;
int n, m; cin >> n >> m;
vector<int> mojeAtakujace(n+1), jegoAtakujace(n+1);
vector< vector<int> > ktoGoAtakuje(n+1);
for (int i = 1; i <= n; ++i) {
mojeAtakujace[i] = 0;
jegoAtakujace[i] = 0;
}
int liczbaJegoAtakujacych = 0;
int liczbaMoichAtakujacych = 0;
for (int i = 0; i < m; ++i) {
int a,b; char w;
cin >> a >> w >> b;
if (w == '>') {
add(liczbaMoichAtakujacych, mojeAtakujace, a);
ktoGoAtakuje[b].push_back(a);
} else {
add(liczbaJegoAtakujacych, jegoAtakujace, b);
}
}
if (liczbaMoichAtakujacych < n && liczbaJegoAtakujacych < n)
cout << "REMIS" << endl;
else if (liczbaJegoAtakujacych == n)
cout << "PRZEGRANA" << endl;
else if (ileRozlacznych(ktoGoAtakuje, n) == 0)
cout << "WYGRANA" << endl;
else
cout << "REMIS" << endl;
//cerr << "------------- END TEST CASE -------------------" << endl;
}
int main() {
ios_base::sync_with_stdio(0);
int t; cin >> t;
while (t--)
testCase();
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 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 | #include <iostream> #include <vector> #include <unordered_set> using namespace std; void add(int& liczba, vector<int>& v, int index) { if (v[index] == 0) liczba++; v[index]++; } int ileRozlacznych(const vector< vector<int> >& ktoGoAtakuje, int n) { vector<int> maPare(n+1); for (int i = 1; i <= n; ++i) maPare[i] = 0; for (int i = 1; i <= n; ++i) { const vector<int>& atakujacy = ktoGoAtakuje[i]; if (atakujacy.size() > 1) { for (int at: atakujacy) maPare[at] = 1; } } int sum = 0; for (int i = 1; i <= n; ++i) sum += maPare[i]; return n - sum; } void testCase() { //cerr << "------------- START TEST CASE -------------------" << endl; int n, m; cin >> n >> m; vector<int> mojeAtakujace(n+1), jegoAtakujace(n+1); vector< vector<int> > ktoGoAtakuje(n+1); for (int i = 1; i <= n; ++i) { mojeAtakujace[i] = 0; jegoAtakujace[i] = 0; } int liczbaJegoAtakujacych = 0; int liczbaMoichAtakujacych = 0; for (int i = 0; i < m; ++i) { int a,b; char w; cin >> a >> w >> b; if (w == '>') { add(liczbaMoichAtakujacych, mojeAtakujace, a); ktoGoAtakuje[b].push_back(a); } else { add(liczbaJegoAtakujacych, jegoAtakujace, b); } } if (liczbaMoichAtakujacych < n && liczbaJegoAtakujacych < n) cout << "REMIS" << endl; else if (liczbaJegoAtakujacych == n) cout << "PRZEGRANA" << endl; else if (ileRozlacznych(ktoGoAtakuje, n) == 0) cout << "WYGRANA" << endl; else cout << "REMIS" << endl; //cerr << "------------- END TEST CASE -------------------" << endl; } int main() { ios_base::sync_with_stdio(0); int t; cin >> t; while (t--) testCase(); return 0; } |
English