#include <iostream>
using namespace std;
struct lustro{
long int w1;
long int w2;
long int h1;
long int h2;
};
int main(){
ios_base::sync_with_stdio(0);
int t;
cin>>t;
for(int i=0;i<t;i++){
int n;
cin>>n;
lustro temp={1000000000,0,1000000000,0};
lustro firmy[n];
for(int j=0;j<n;j++){
cin>>firmy[j].w1>>firmy[j].w2>>firmy[j].h1>>firmy[j].h2;
if(temp.w1>=firmy[j].w1) temp.w1=firmy[j].w1;
if(temp.w2<=firmy[j].w2) temp.w2=firmy[j].w2;
if(temp.h1>=firmy[j].h1) temp.h1=firmy[j].h1;
if(temp.h2<=firmy[j].h2) temp.h2=firmy[j].h2;
}
for(int j=0;j<n;j++){
if(temp.w1>=firmy[j].w1 && temp.w2<=firmy[j].w2 && temp.h1>=firmy[j].h1 && temp.h2<=firmy[j].h2){
cout<<"TAK";
break;
}
if(j+1==n){
cout<<"NIE";
}
}
if(i+1!=t) cout<<endl; //enteroo na koncu
}
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 | #include <iostream> using namespace std; struct lustro{ long int w1; long int w2; long int h1; long int h2; }; int main(){ ios_base::sync_with_stdio(0); int t; cin>>t; for(int i=0;i<t;i++){ int n; cin>>n; lustro temp={1000000000,0,1000000000,0}; lustro firmy[n]; for(int j=0;j<n;j++){ cin>>firmy[j].w1>>firmy[j].w2>>firmy[j].h1>>firmy[j].h2; if(temp.w1>=firmy[j].w1) temp.w1=firmy[j].w1; if(temp.w2<=firmy[j].w2) temp.w2=firmy[j].w2; if(temp.h1>=firmy[j].h1) temp.h1=firmy[j].h1; if(temp.h2<=firmy[j].h2) temp.h2=firmy[j].h2; } for(int j=0;j<n;j++){ if(temp.w1>=firmy[j].w1 && temp.w2<=firmy[j].w2 && temp.h1>=firmy[j].h1 && temp.h2<=firmy[j].h2){ cout<<"TAK"; break; } if(j+1==n){ cout<<"NIE"; } } if(i+1!=t) cout<<endl; //enteroo na koncu } return 0; } |
English