#include <vector> #include <math.h> #include <string> #include <iostream> #include <sstream> #include <limits> #include <cstring> //#define PA2016_TEST #ifdef PA2016_TEST #define ASSERT( condition ) if ( !( condition ) ) { __debugbreak(); } #define PAUSE_CONSOLE system( "pause" ); #define DEBUG_ONLY( line ) line; #else #define ASSERT( condition ) #define PAUSE_CONSOLE #define DEBUG_ONLY( line ) #endif typedef unsigned int uint; static const char* WIN = "WYGRANA"; static const char* LOST = "PRZEGRANA"; static const char* DRAW = "REMIS"; char g_myWinDeckMarks[ 100000 ] = { 0 }; char g_opWinDeckMarks[ 100000 ] = { 0 }; const char* ProcessOneGame( uint allDecks, uint myUniqueDecks, uint opUniqueDecks ) { // Simple decision tree: if( myUniqueDecks == allDecks ) { if( opUniqueDecks == allDecks ) return LOST; else return WIN; } else { if( opUniqueDecks == allDecks ) return LOST; else return DRAW; } } const char* ProcessOneTest() { uint numOfDecks = 0; std::cin >> numOfDecks; uint numOfPairs = 0; std::cin >> numOfPairs; uint numOfMyUniqueWinDecks = 0; uint numOfOpUniqueWinDecks = 0; memset( g_myWinDeckMarks, 0, sizeof( g_myWinDeckMarks ) ); memset( g_opWinDeckMarks, 0, sizeof( g_opWinDeckMarks ) ); for( uint i = 0; i < numOfPairs; ++i ) { uint myDeck = 0; uint opDeck = 0; char sign = 0; std::cin >> myDeck; std::cin >> sign; std::cin >> opDeck; if( sign == '>' ) { if( !g_myWinDeckMarks[ myDeck ]++ ) ++numOfMyUniqueWinDecks; } else { if( !g_opWinDeckMarks[ opDeck ]++ ) ++numOfOpUniqueWinDecks; } } return ProcessOneGame( numOfDecks, numOfMyUniqueWinDecks, numOfOpUniqueWinDecks ); } int main() { std::vector< const char* > output; uint numOfTests = 0; std::cin >> numOfTests; output.reserve( numOfTests ); for( uint i = 0; i < numOfTests; ++i ) { const char* txt = ProcessOneTest(); output.push_back( txt ); } for( const char* txt : output ) { std::cout << txt << "\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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | #include <vector> #include <math.h> #include <string> #include <iostream> #include <sstream> #include <limits> #include <cstring> //#define PA2016_TEST #ifdef PA2016_TEST #define ASSERT( condition ) if ( !( condition ) ) { __debugbreak(); } #define PAUSE_CONSOLE system( "pause" ); #define DEBUG_ONLY( line ) line; #else #define ASSERT( condition ) #define PAUSE_CONSOLE #define DEBUG_ONLY( line ) #endif typedef unsigned int uint; static const char* WIN = "WYGRANA"; static const char* LOST = "PRZEGRANA"; static const char* DRAW = "REMIS"; char g_myWinDeckMarks[ 100000 ] = { 0 }; char g_opWinDeckMarks[ 100000 ] = { 0 }; const char* ProcessOneGame( uint allDecks, uint myUniqueDecks, uint opUniqueDecks ) { // Simple decision tree: if( myUniqueDecks == allDecks ) { if( opUniqueDecks == allDecks ) return LOST; else return WIN; } else { if( opUniqueDecks == allDecks ) return LOST; else return DRAW; } } const char* ProcessOneTest() { uint numOfDecks = 0; std::cin >> numOfDecks; uint numOfPairs = 0; std::cin >> numOfPairs; uint numOfMyUniqueWinDecks = 0; uint numOfOpUniqueWinDecks = 0; memset( g_myWinDeckMarks, 0, sizeof( g_myWinDeckMarks ) ); memset( g_opWinDeckMarks, 0, sizeof( g_opWinDeckMarks ) ); for( uint i = 0; i < numOfPairs; ++i ) { uint myDeck = 0; uint opDeck = 0; char sign = 0; std::cin >> myDeck; std::cin >> sign; std::cin >> opDeck; if( sign == '>' ) { if( !g_myWinDeckMarks[ myDeck ]++ ) ++numOfMyUniqueWinDecks; } else { if( !g_opWinDeckMarks[ opDeck ]++ ) ++numOfOpUniqueWinDecks; } } return ProcessOneGame( numOfDecks, numOfMyUniqueWinDecks, numOfOpUniqueWinDecks ); } int main() { std::vector< const char* > output; uint numOfTests = 0; std::cin >> numOfTests; output.reserve( numOfTests ); for( uint i = 0; i < numOfTests; ++i ) { const char* txt = ProcessOneTest(); output.push_back( txt ); } for( const char* txt : output ) { std::cout << txt << "\n"; } return 0; } |