#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
for(int d=0;d<t;d++){
int n;
cin>>n;
int tab[n][4];
int i=0;
for (i=0;i<n;i++){
for(int j=0;j<4;j++){
cin>>tab[i][j];
}
}
int w1,w2,h1,h2;
w1=tab[0][0];
w2=tab[0][1];
h1=tab[0][2];
h2=tab[0][3];
for (int i=1;i<n;i++){
if(tab[i][0]<w1) w1=tab[i][0];
if(tab[i][1]>w2) w2=tab[i][1];
if(tab[i][2]<h1) h1=tab[i][2];
if(tab[i][3]>h2) h2=tab[i][3];
}
bool odp=false;
for (i=0;i<n;i++){
if(tab[i][0]==w1)
if(tab[i][1]==w2)
if(tab[i][2]==h1)
if(tab[i][3]==h2){
odp=true;
break;
}
}
if(odp)cout<<"TAK"<<endl;
else cout<<"NIE"<<endl;
}
}
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 | #include <iostream> using namespace std; int main() { int t; cin>>t; for(int d=0;d<t;d++){ int n; cin>>n; int tab[n][4]; int i=0; for (i=0;i<n;i++){ for(int j=0;j<4;j++){ cin>>tab[i][j]; } } int w1,w2,h1,h2; w1=tab[0][0]; w2=tab[0][1]; h1=tab[0][2]; h2=tab[0][3]; for (int i=1;i<n;i++){ if(tab[i][0]<w1) w1=tab[i][0]; if(tab[i][1]>w2) w2=tab[i][1]; if(tab[i][2]<h1) h1=tab[i][2]; if(tab[i][3]>h2) h2=tab[i][3]; } bool odp=false; for (i=0;i<n;i++){ if(tab[i][0]==w1) if(tab[i][1]==w2) if(tab[i][2]==h1) if(tab[i][3]==h2){ odp=true; break; } } if(odp)cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } } |
English