// // main.cpp // KAR // // Created by Andrzej Michnia on 22.11.2016. // Copyright © 2016 intive. All rights reserved. // #include <stdio.h> inline void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int main(int argc, const char * argv[]) { int t = 0; // Test cases scanf("%d",&t); while (t--) { // Input for test case int m,n; scanf("%d%d",&n,&m); // Declare int deckIn[n+5]; int deckOut[n+5]; // Initial clear of data for (int i=1;i<=n;i++) { deckIn[i] = 0; deckOut[i] = 0; } // Scan M pairs for (int i=0;i<m;i++) { int a,b; char str[3]; scanf("%d%s%d",&a,str,&b); char w = str[0]; // player A (Bajtek) deck a is better than player B (Bitek) deck b if (w == '>') { deckIn[b] += 1; } // player B (Bitek) deck b is better than player A (Bajtek) deck a else if (w == '<') { deckOut[b] += 1; } else { return 1; } } // Check WIN LOSE TIE int result = -1; for (int i=1;i<=n;i++) { // Check if winning if (deckIn[i] >= n) { result = 1; break; } // Check if losing impossible if (deckOut[i] <= 0) { result = 0; } } if (result == 1) { printf("WYGRANA\n"); } else if (result == -1) { printf("PRZEGRANA\n"); } else { printf("REMIS\n"); } } 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 79 80 81 82 83 84 85 86 87 | // // main.cpp // KAR // // Created by Andrzej Michnia on 22.11.2016. // Copyright © 2016 intive. All rights reserved. // #include <stdio.h> inline void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int main(int argc, const char * argv[]) { int t = 0; // Test cases scanf("%d",&t); while (t--) { // Input for test case int m,n; scanf("%d%d",&n,&m); // Declare int deckIn[n+5]; int deckOut[n+5]; // Initial clear of data for (int i=1;i<=n;i++) { deckIn[i] = 0; deckOut[i] = 0; } // Scan M pairs for (int i=0;i<m;i++) { int a,b; char str[3]; scanf("%d%s%d",&a,str,&b); char w = str[0]; // player A (Bajtek) deck a is better than player B (Bitek) deck b if (w == '>') { deckIn[b] += 1; } // player B (Bitek) deck b is better than player A (Bajtek) deck a else if (w == '<') { deckOut[b] += 1; } else { return 1; } } // Check WIN LOSE TIE int result = -1; for (int i=1;i<=n;i++) { // Check if winning if (deckIn[i] >= n) { result = 1; break; } // Check if losing impossible if (deckOut[i] <= 0) { result = 0; } } if (result == 1) { printf("WYGRANA\n"); } else if (result == -1) { printf("PRZEGRANA\n"); } else { printf("REMIS\n"); } } return 0; } |