/* 2016 * Maciej Szeptuch */ #include <cstdio> const int MAX_DECKS = 131072; bool second_each_can_win; bool second_has_worst_deck; char relation[4]; int decks; int relations; int second; int second_in[MAX_DECKS]; int second_out[MAX_DECKS]; int tests; int main(void) { scanf("%d", &tests); for(int t = 0; t < tests; ++ t) { second_each_can_win = true; second_has_worst_deck = false; scanf("%d %d", &decks, &relations); for(int r = 0; r < relations; ++ r) { scanf("%*d %s %d", relation, &second); -- second; if(relation[0] == '>') ++ second_in[second]; else ++ second_out[second]; } for(int d = 0; d < decks; ++ d) { if(second_in[d] == decks) second_has_worst_deck = true; second_each_can_win &= (second_out[d] > 0); second_in[d] = second_out[d] = 0; } puts(second_has_worst_deck ? "WYGRANA" : second_each_can_win ? "PRZEGRANA" : "REMIS"); } 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 | /* 2016 * Maciej Szeptuch */ #include <cstdio> const int MAX_DECKS = 131072; bool second_each_can_win; bool second_has_worst_deck; char relation[4]; int decks; int relations; int second; int second_in[MAX_DECKS]; int second_out[MAX_DECKS]; int tests; int main(void) { scanf("%d", &tests); for(int t = 0; t < tests; ++ t) { second_each_can_win = true; second_has_worst_deck = false; scanf("%d %d", &decks, &relations); for(int r = 0; r < relations; ++ r) { scanf("%*d %s %d", relation, &second); -- second; if(relation[0] == '>') ++ second_in[second]; else ++ second_out[second]; } for(int d = 0; d < decks; ++ d) { if(second_in[d] == decks) second_has_worst_deck = true; second_each_can_win &= (second_out[d] > 0); second_in[d] = second_out[d] = 0; } puts(second_has_worst_deck ? "WYGRANA" : second_each_can_win ? "PRZEGRANA" : "REMIS"); } return 0; } |