#include<stdio.h> #include<iostream> /* #include<vector> #include<string> #include<map> #include<complex> #include<stack> #include<list> #include<set> #include<bitset> #include<set> #include<iterator> #include<cmath> #include<queue> #include<time.h> #include<string.h> #include<fstream> #include<sstream> #include<algorithm>*/ using namespace std; #define REP( x,y ) for( int x=0; x<(y); x++ ) #define FORD( x,y,z ) for( int x=y; x>=(z); x-- ) #define FOR(x,b,e) for( int x = b; x <= (e); ++x ) #define SIZE(v) (int)v.size() #define ALL(c) c.begin(),c.end() #define VAR(v,n) __typeof(n) v=(n) #define FOREACH(i,c) for( VAR(i,c.begin());i!=c.end();++i ) #define PB push_back #define MP make_pair #define ST first #define ND second #define WRITE( V ){ FOREACH(it,V) cout << *it << ", "; cout << endl; } #define WRITE_ALL(V,s,t) { cout << s << endl; REP( i,SIZE(V) ){ cout << i+1 << " ---- "; FOREACH(it,V[i]) cout << *it+t << ", "; cout << endl; } } #define WRP(p) p.ST << " " << p.ND #define CLEAR( dst,quant ) memset( dst,0, (quant)*sizeof( __typeof(*dst) ) ); #define WAR if( show_help ) #define ENDL(x) REP(crow,(x)) cout << endl; const bool show_help = 1; const int INF = 1000000001; int N,M,K,a,b,c,y,t,w,l_zest; /* const long double EPS = 1e-11; typedef vector<double> VD; typedef pair<double,int> PDI; typedef pair<double, double> PDD; typedef vector<bool> VB; typedef vector<int> VI; typedef vector< VI > VVI; typedef pair<int,int> PII; typedef map< PII, bool > MPIIB; typedef long long LL; typedef pair<LL,LL> PLL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<PII> VPII;*/ int minw1,minh1,maxw2,maxh2,majw1,majw2,majh1,majh2, w1,w2,h1,h2; void przepisz(){ majw1 = w1; majw2 = w2; majh1 = h1; majh2 = h2; } int main(){ ios_base::sync_with_stdio(0); cin >> l_zest; while( l_zest-- ){ cin >> N; minw1 = minh1 = INF; maxw2 = maxh2 = 0; majw1 = majh1 = INF; majw2 = majh2 = 0; REP(i,N){ cin >> w1 >> w2 >> h1 >> h2; minw1 = min( minw1, w1 ); minh1 = min( minh1, h1 ); maxw2 = max( maxw2, w2 ); maxh2 = max( maxh2, h2 ); if( w1 < majw1 ) przepisz(); else if( w1 == majw1 && w2 > majw2 ) przepisz(); else if( w1 == majw1 && w2 == majw2 && h1 < majh1 ) przepisz(); else if( w1 == majw1 && w2 == majw2 && h1 == majh1 && h2 > majh2 ) przepisz(); } // koniec REP'a if( minw1 != majw1 || maxw2 != majw2 || minh1 != majh1 || maxh2 != majh2 ) cout << "NIE" << endl; else cout << "TAK" << endl; // if( !( minw1 != majw1 || maxw2 != majw2 || minh1 != majh1 || maxh2 != majh2 ) ) cout << majw1 << " " << majw2 << " " << majh1 << " " << majh2 << endl; } 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<stdio.h> #include<iostream> /* #include<vector> #include<string> #include<map> #include<complex> #include<stack> #include<list> #include<set> #include<bitset> #include<set> #include<iterator> #include<cmath> #include<queue> #include<time.h> #include<string.h> #include<fstream> #include<sstream> #include<algorithm>*/ using namespace std; #define REP( x,y ) for( int x=0; x<(y); x++ ) #define FORD( x,y,z ) for( int x=y; x>=(z); x-- ) #define FOR(x,b,e) for( int x = b; x <= (e); ++x ) #define SIZE(v) (int)v.size() #define ALL(c) c.begin(),c.end() #define VAR(v,n) __typeof(n) v=(n) #define FOREACH(i,c) for( VAR(i,c.begin());i!=c.end();++i ) #define PB push_back #define MP make_pair #define ST first #define ND second #define WRITE( V ){ FOREACH(it,V) cout << *it << ", "; cout << endl; } #define WRITE_ALL(V,s,t) { cout << s << endl; REP( i,SIZE(V) ){ cout << i+1 << " ---- "; FOREACH(it,V[i]) cout << *it+t << ", "; cout << endl; } } #define WRP(p) p.ST << " " << p.ND #define CLEAR( dst,quant ) memset( dst,0, (quant)*sizeof( __typeof(*dst) ) ); #define WAR if( show_help ) #define ENDL(x) REP(crow,(x)) cout << endl; const bool show_help = 1; const int INF = 1000000001; int N,M,K,a,b,c,y,t,w,l_zest; /* const long double EPS = 1e-11; typedef vector<double> VD; typedef pair<double,int> PDI; typedef pair<double, double> PDD; typedef vector<bool> VB; typedef vector<int> VI; typedef vector< VI > VVI; typedef pair<int,int> PII; typedef map< PII, bool > MPIIB; typedef long long LL; typedef pair<LL,LL> PLL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<PII> VPII;*/ int minw1,minh1,maxw2,maxh2,majw1,majw2,majh1,majh2, w1,w2,h1,h2; void przepisz(){ majw1 = w1; majw2 = w2; majh1 = h1; majh2 = h2; } int main(){ ios_base::sync_with_stdio(0); cin >> l_zest; while( l_zest-- ){ cin >> N; minw1 = minh1 = INF; maxw2 = maxh2 = 0; majw1 = majh1 = INF; majw2 = majh2 = 0; REP(i,N){ cin >> w1 >> w2 >> h1 >> h2; minw1 = min( minw1, w1 ); minh1 = min( minh1, h1 ); maxw2 = max( maxw2, w2 ); maxh2 = max( maxh2, h2 ); if( w1 < majw1 ) przepisz(); else if( w1 == majw1 && w2 > majw2 ) przepisz(); else if( w1 == majw1 && w2 == majw2 && h1 < majh1 ) przepisz(); else if( w1 == majw1 && w2 == majw2 && h1 == majh1 && h2 > majh2 ) przepisz(); } // koniec REP'a if( minw1 != majw1 || maxw2 != majw2 || minh1 != majh1 || maxh2 != majh2 ) cout << "NIE" << endl; else cout << "TAK" << endl; // if( !( minw1 != majw1 || maxw2 != majw2 || minh1 != majh1 || maxh2 != majh2 ) ) cout << majw1 << " " << majw2 << " " << majh1 << " " << majh2 << endl; } return 0; } |