#include <iostream> using namespace std; int main() {int imain,ilefirm,w1,w2,h1,h2,w1n,w2n,h2n,h1n; bool b; cin.sync_with_stdio(false); cin>>imain; for (;imain>=1;imain--) { cin>>ilefirm; ilefirm--; cin>>w1>>w2>>h1>>h2; b=true; //cout<<ilefirm<<" tu"<<endl; for(;ilefirm>=1;ilefirm--) { cin>>w1n>>w2n>>h1n>>h2n; if(w1n<=w1 && w2n>=w2 && h1n<=h1 && h2n>=h2) { b=true; w1=w1n; h1=h1n; w2=w2n; h2=h2n; } else { if(w1n<w1) { w1=w1n; b=false; } if(w2n>w2) { w2=w2n; b=false; } if(h1n<h1) { h1=h1n; b=false; } if(h2n>h2) { h2=h2n; b=false; } } } if (b) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } 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 57 58 59 | #include <iostream> using namespace std; int main() {int imain,ilefirm,w1,w2,h1,h2,w1n,w2n,h2n,h1n; bool b; cin.sync_with_stdio(false); cin>>imain; for (;imain>=1;imain--) { cin>>ilefirm; ilefirm--; cin>>w1>>w2>>h1>>h2; b=true; //cout<<ilefirm<<" tu"<<endl; for(;ilefirm>=1;ilefirm--) { cin>>w1n>>w2n>>h1n>>h2n; if(w1n<=w1 && w2n>=w2 && h1n<=h1 && h2n>=h2) { b=true; w1=w1n; h1=h1n; w2=w2n; h2=h2n; } else { if(w1n<w1) { w1=w1n; b=false; } if(w2n>w2) { w2=w2n; b=false; } if(h1n<h1) { h1=h1n; b=false; } if(h2n>h2) { h2=h2n; b=false; } } } if (b) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } return 0; } |