#include<iostream> using namespace std; int main(){ios_base::sync_with_stdio(0); int poert; int n; int w1,w2,h1,h2; int w3,w4,h3,h4; char tak; cin >> poert; for(int i=0;i<poert;i++){ cin >> n>>w1>>w2>>h1>>h2; tak=0; for(int i=1;i<n;i++){ cin>>w3>>w4>>h3>>h4; if(w3<=w1&&w4>=w2&&h3<=h1&&h4>=h2){w1=w3;w2=w4;h1=h3;h2=h4;tak=1;continue;} if(w3<w1){w1=w3;tak=0;} if(w4>w2){w2=w4;tak=0;} if(h3<h1){h1=h3;tak=0;} if(h4>h2){h2=h4;tak=0;} } if(tak==1){cout<<"TAK\n";}else{cout<<"NIE\n";} } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<iostream> using namespace std; int main(){ios_base::sync_with_stdio(0); int poert; int n; int w1,w2,h1,h2; int w3,w4,h3,h4; char tak; cin >> poert; for(int i=0;i<poert;i++){ cin >> n>>w1>>w2>>h1>>h2; tak=0; for(int i=1;i<n;i++){ cin>>w3>>w4>>h3>>h4; if(w3<=w1&&w4>=w2&&h3<=h1&&h4>=h2){w1=w3;w2=w4;h1=h3;h2=h4;tak=1;continue;} if(w3<w1){w1=w3;tak=0;} if(w4>w2){w2=w4;tak=0;} if(h3<h1){h1=h3;tak=0;} if(h4>h2){h2=h4;tak=0;} } if(tak==1){cout<<"TAK\n";}else{cout<<"NIE\n";} } } |