#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define INF (1 << 30) #define SQR(a) ((a) * (a)) using namespace std; const int N = 1111; int n, m; void foo() { cin >> n >> m; set<int> firstAttackers; set<int> firstAttack; set<int> secondAttackers; set<int> secondAttack; while (m--) { int a, b; char c; cin >> a >> c >> b; if (c == '<') { secondAttackers.insert(b); secondAttack.insert(a); } else { firstAttackers.insert(a); firstAttack.insert(b); } } // if each of them attacks something of ours, we are // doomed because he'll just keep the amount of attacked figures // more than 1 at all times. if ((int)secondAttackers.size() == n) { cout << "PRZEGRANA" << endl; return; } // now we can definitely get a draw by taking out all decks // except for one that doesn't beat any of our decks // if not all our decks beat something of second player's, we'll just get a draw // we can't do better if ((int)firstAttackers.size() < n) { cout << "REMIS" << endl; return; } // we can win only if all our decks beat one of the second player's deck, and this deck // doesn't beat anything from our deck if (firstAttack.size() == 1 && secondAttackers.find(*firstAttack.begin()) == secondAttackers.end()) { cout << "WYGRANA" << endl; return; } cout << "REMIS" << endl; } int main() { //freopen("input.txt", "r", stdin); ios::sync_with_stdio(false); int t; cin >> t; while (t--) { foo(); } 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 74 | #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define INF (1 << 30) #define SQR(a) ((a) * (a)) using namespace std; const int N = 1111; int n, m; void foo() { cin >> n >> m; set<int> firstAttackers; set<int> firstAttack; set<int> secondAttackers; set<int> secondAttack; while (m--) { int a, b; char c; cin >> a >> c >> b; if (c == '<') { secondAttackers.insert(b); secondAttack.insert(a); } else { firstAttackers.insert(a); firstAttack.insert(b); } } // if each of them attacks something of ours, we are // doomed because he'll just keep the amount of attacked figures // more than 1 at all times. if ((int)secondAttackers.size() == n) { cout << "PRZEGRANA" << endl; return; } // now we can definitely get a draw by taking out all decks // except for one that doesn't beat any of our decks // if not all our decks beat something of second player's, we'll just get a draw // we can't do better if ((int)firstAttackers.size() < n) { cout << "REMIS" << endl; return; } // we can win only if all our decks beat one of the second player's deck, and this deck // doesn't beat anything from our deck if (firstAttack.size() == 1 && secondAttackers.find(*firstAttack.begin()) == secondAttackers.end()) { cout << "WYGRANA" << endl; return; } cout << "REMIS" << endl; } int main() { //freopen("input.txt", "r", stdin); ios::sync_with_stdio(false); int t; cin >> t; while (t--) { foo(); } return 0; } |