#include <cstdio> bool opponents_deck_is_wining[110000]; int opponents_deck_losing_num[110000]; void clear_tables() { for (int i = 0; i < 110000; i++) { opponents_deck_losing_num[i] = 0; opponents_deck_is_wining[i] = false; } } bool Bajtek_wins(int decks) { for (int i = 1; i <= decks; i++) { if (opponents_deck_losing_num[i] == decks) { return true; } } return false; } bool Bajtek_lose(int decks) { for (int i = 1; i <= decks; i++) { if (opponents_deck_is_wining[i] == false) { return false; } } return true; } void perform_match() { int decks_num; int winning_num; scanf("%d %d", &decks_num, &winning_num); clear_tables(); int Bajteks_deck; int opponents_deck; char sign; for (int i = 0; i < winning_num; i++) { scanf("%d %c %d", &Bajteks_deck, &sign, &opponents_deck); if (sign == '>') { opponents_deck_losing_num[opponents_deck]++; } else { opponents_deck_is_wining[opponents_deck] = true; } } if (Bajtek_wins(decks_num)) { printf("WYGRANA\n"); } else if (Bajtek_lose(decks_num)) { printf("PRZEGRANA\n"); } else { printf("REMIS\n"); } } int main(void) { int matches_num; scanf("%d", &matches_num); for (int i = 0; i < matches_num; i++) { perform_match(); } 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 75 76 77 78 | #include <cstdio> bool opponents_deck_is_wining[110000]; int opponents_deck_losing_num[110000]; void clear_tables() { for (int i = 0; i < 110000; i++) { opponents_deck_losing_num[i] = 0; opponents_deck_is_wining[i] = false; } } bool Bajtek_wins(int decks) { for (int i = 1; i <= decks; i++) { if (opponents_deck_losing_num[i] == decks) { return true; } } return false; } bool Bajtek_lose(int decks) { for (int i = 1; i <= decks; i++) { if (opponents_deck_is_wining[i] == false) { return false; } } return true; } void perform_match() { int decks_num; int winning_num; scanf("%d %d", &decks_num, &winning_num); clear_tables(); int Bajteks_deck; int opponents_deck; char sign; for (int i = 0; i < winning_num; i++) { scanf("%d %c %d", &Bajteks_deck, &sign, &opponents_deck); if (sign == '>') { opponents_deck_losing_num[opponents_deck]++; } else { opponents_deck_is_wining[opponents_deck] = true; } } if (Bajtek_wins(decks_num)) { printf("WYGRANA\n"); } else if (Bajtek_lose(decks_num)) { printf("PRZEGRANA\n"); } else { printf("REMIS\n"); } } int main(void) { int matches_num; scanf("%d", &matches_num); for (int i = 0; i < matches_num; i++) { perform_match(); } return 0; } |