#include <iostream> #include <cstdio> using namespace std; int main(){ int z; int n; scanf("%d",&z); int W[100010];int ww[100010];int H[100010];int hh[100010]; int P[100010]; bool maj=false; for(int h=0;h<z;h++){ scanf("%d",&n); for(int i=0;i<n;i++)P[i]=0; maj=false; int maxW=0;int minW=2000000000; int maxH=0; int minH=2000000000; for(int i=0;i<n;i++){ scanf("%d %d %d %d",&ww[i],&W[i],&hh[i],&H[i]); } for(int i=0;i<n;i++){ if(maxW<=W[i]){maxW=W[i];} if(minW>=ww[i]){minW=ww[i];} if(maxH<=H[i]){maxH=H[i];} if(minH>=hh[i]){minH=hh[i];} } for(int i=0;i<n;i++){ if(maxW==W[i]){P[i]+=1;} if(minW==ww[i]){P[i]+=10;} if(maxH==H[i]){P[i]+=100;} if(minH==hh[i]){P[i]+=1000;} if(P[i]==1111){maj=true;break;} } // for(int i=0;i<n;i++){ // cout<<W[i]<<" "<<ww[i]<<" "<<H[i]<<" "<<hh[i]<<" * P= "<<P[i]<<endl;} if(maj==true){ printf("TAK\n"); }else{ printf("NIE\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 | #include <iostream> #include <cstdio> using namespace std; int main(){ int z; int n; scanf("%d",&z); int W[100010];int ww[100010];int H[100010];int hh[100010]; int P[100010]; bool maj=false; for(int h=0;h<z;h++){ scanf("%d",&n); for(int i=0;i<n;i++)P[i]=0; maj=false; int maxW=0;int minW=2000000000; int maxH=0; int minH=2000000000; for(int i=0;i<n;i++){ scanf("%d %d %d %d",&ww[i],&W[i],&hh[i],&H[i]); } for(int i=0;i<n;i++){ if(maxW<=W[i]){maxW=W[i];} if(minW>=ww[i]){minW=ww[i];} if(maxH<=H[i]){maxH=H[i];} if(minH>=hh[i]){minH=hh[i];} } for(int i=0;i<n;i++){ if(maxW==W[i]){P[i]+=1;} if(minW==ww[i]){P[i]+=10;} if(maxH==H[i]){P[i]+=100;} if(minH==hh[i]){P[i]+=1000;} if(P[i]==1111){maj=true;break;} } // for(int i=0;i<n;i++){ // cout<<W[i]<<" "<<ww[i]<<" "<<H[i]<<" "<<hh[i]<<" * P= "<<P[i]<<endl;} if(maj==true){ printf("TAK\n"); }else{ printf("NIE\n"); } } return 0; } |