#include <cstdio> #include <vector> using namespace std; vector< pair< pair< int, int >, pair< int, int > > > v; int main(){ int t; scanf( "%d", &t ); while( t-- ){ int n; scanf( "%d", &n ); v.clear(); int h_max = -1; int w_max = -1; int max_index = -1; for( int i = 0; i < n; i++ ){ int h1, h2, w1, w2; scanf( "%d %d %d %d", &w1, &w2, &h1, &h2 ); v.push_back( make_pair( make_pair( w1, w2 ), make_pair( h1, h2 ) ) ); if( w2 - w1 > w_max ){ max_index = i; w_max = w2 - w1; h_max = h2 - h1; } if( w2 - w1 == w_max && h2 - h1 > h_max ){ max_index = i; w_max = w2 - w1; h_max = h2 - h1; } } int major = true; for( int i = 0; i < n; i++ ){ if( v[ i ].first.first < v[ max_index ].first.first || v[ i ].first.second > v[ max_index ].first.second ){ major = false; break; } if( v[ i ].second.first < v[ max_index ].second.first || v[ i ].second.second > v[ max_index ].second.second ){ major = false; break; } } if( major ) printf( "TAK\n" ); else printf( "NIE\n" ); } }
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 | #include <cstdio> #include <vector> using namespace std; vector< pair< pair< int, int >, pair< int, int > > > v; int main(){ int t; scanf( "%d", &t ); while( t-- ){ int n; scanf( "%d", &n ); v.clear(); int h_max = -1; int w_max = -1; int max_index = -1; for( int i = 0; i < n; i++ ){ int h1, h2, w1, w2; scanf( "%d %d %d %d", &w1, &w2, &h1, &h2 ); v.push_back( make_pair( make_pair( w1, w2 ), make_pair( h1, h2 ) ) ); if( w2 - w1 > w_max ){ max_index = i; w_max = w2 - w1; h_max = h2 - h1; } if( w2 - w1 == w_max && h2 - h1 > h_max ){ max_index = i; w_max = w2 - w1; h_max = h2 - h1; } } int major = true; for( int i = 0; i < n; i++ ){ if( v[ i ].first.first < v[ max_index ].first.first || v[ i ].first.second > v[ max_index ].first.second ){ major = false; break; } if( v[ i ].second.first < v[ max_index ].second.first || v[ i ].second.second > v[ max_index ].second.second ){ major = false; break; } } if( major ) printf( "TAK\n" ); else printf( "NIE\n" ); } } |