#include <iostream> #include <map> #include <set> void process_test_case() { int N = 0; int M = 0; std::cin >> N; std::cin >> M; std::set<int> conn_to_left; // set with Vs having conn to the left std::map<int, std::set<int>> conn_to_right; // <right V, set<left V>> for (int i = 0; i < M; ++i) { int left = 0, right = 0; char c = 0; std::cin >> left; std::cin >> c; std::cin >> right; if (c == '<') { conn_to_left.insert(right); } else { conn_to_right[right].insert(left); } } // if (conn_to_left.size() == (size_t) N) { std::cout << "PRZEGRANA" << std::endl; return; } // for (const auto &p : conn_to_right) { if (p.second.size() == (size_t) N) { std::cout << "WYGRANA" << std::endl; return; } } // std::cout << "REMIS" << std::endl; } int main() { std::ios_base::sync_with_stdio(0); int T = 0; std::cin >> T; for (int i = 0; i < T; ++i) { process_test_case(); } 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 | #include <iostream> #include <map> #include <set> void process_test_case() { int N = 0; int M = 0; std::cin >> N; std::cin >> M; std::set<int> conn_to_left; // set with Vs having conn to the left std::map<int, std::set<int>> conn_to_right; // <right V, set<left V>> for (int i = 0; i < M; ++i) { int left = 0, right = 0; char c = 0; std::cin >> left; std::cin >> c; std::cin >> right; if (c == '<') { conn_to_left.insert(right); } else { conn_to_right[right].insert(left); } } // if (conn_to_left.size() == (size_t) N) { std::cout << "PRZEGRANA" << std::endl; return; } // for (const auto &p : conn_to_right) { if (p.second.size() == (size_t) N) { std::cout << "WYGRANA" << std::endl; return; } } // std::cout << "REMIS" << std::endl; } int main() { std::ios_base::sync_with_stdio(0); int T = 0; std::cin >> T; for (int i = 0; i < T; ++i) { process_test_case(); } return 0; } |