#include<cstdio> using namespace std; int tab[10000][4]; int main() { int t,n,w1,w2,h1,h2; scanf("%d",&t); for(int i=0;i<t;++i) { int wmin=-1,wmax=-1,hmin=-1,hmax=-1; scanf("%d",&n); for(int j=0;j<n;++j) { scanf("%d %d %d %d",&w1,&w2,&h1,&h2); tab[j][0]=w1; tab[j][1]=w2; tab[j][2]=h1; tab[j][3]=h2; if(wmin==-1) wmin=w1; else if(w1<wmin) wmin=w1; if(wmax==-1) wmax=w2; else if(w2>wmax) wmax=w2; if(hmin==-1) hmin=h1; else if(h1<hmin) hmin=h1; if(hmax==-1) hmax=h2; else if(h2>hmax) hmax=h2; } for(int j=0;j<n;++j) { if(tab[j][0]==wmin && tab[j][1]==wmax && tab[j][2]==hmin && tab[j][3]==hmax) { printf("TAK\n"); goto koniec; } } printf("NIE\n"); koniec: ; } 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 | #include<cstdio> using namespace std; int tab[10000][4]; int main() { int t,n,w1,w2,h1,h2; scanf("%d",&t); for(int i=0;i<t;++i) { int wmin=-1,wmax=-1,hmin=-1,hmax=-1; scanf("%d",&n); for(int j=0;j<n;++j) { scanf("%d %d %d %d",&w1,&w2,&h1,&h2); tab[j][0]=w1; tab[j][1]=w2; tab[j][2]=h1; tab[j][3]=h2; if(wmin==-1) wmin=w1; else if(w1<wmin) wmin=w1; if(wmax==-1) wmax=w2; else if(w2>wmax) wmax=w2; if(hmin==-1) hmin=h1; else if(h1<hmin) hmin=h1; if(hmax==-1) hmax=h2; else if(h2>hmax) hmax=h2; } for(int j=0;j<n;++j) { if(tab[j][0]==wmin && tab[j][1]==wmax && tab[j][2]==hmin && tab[j][3]==hmax) { printf("TAK\n"); goto koniec; } } printf("NIE\n"); koniec: ; } return 0; } |