#include<iostream> using namespace std; int main() { int testy,n; bool tak; cin >> testy; while(testy--) { int w1,w2,h1,h2,W1=1000000003,W2=0,H1=1000000003,H2=0; cin >> n; for(int i=0; i<n; i++) { cin >> w1 >> w2 >> h1 >> h2; if(w1<=W1 && w2>=W2 && h1<=H1 && h2>=H2){ tak=1; W1=w1; W2=w2; H1=h1; H2=h2; } else if (w1<W1 || w2>W2 || h1<H1 || h2>H2){ tak=0; W1 = (w1<W1? w1 : W1); W2 = (w2>W2? w2 : W2); H1 = (h1<H1? h1 : H1); H2 = (h2>H2? h2 : H2); } } if(tak) cout << "TAK\n"; else cout << "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 | #include<iostream> using namespace std; int main() { int testy,n; bool tak; cin >> testy; while(testy--) { int w1,w2,h1,h2,W1=1000000003,W2=0,H1=1000000003,H2=0; cin >> n; for(int i=0; i<n; i++) { cin >> w1 >> w2 >> h1 >> h2; if(w1<=W1 && w2>=W2 && h1<=H1 && h2>=H2){ tak=1; W1=w1; W2=w2; H1=h1; H2=h2; } else if (w1<W1 || w2>W2 || h1<H1 || h2>H2){ tak=0; W1 = (w1<W1? w1 : W1); W2 = (w2>W2? w2 : W2); H1 = (h1<H1? h1 : H1); H2 = (h2>H2? h2 : H2); } } if(tak) cout << "TAK\n"; else cout << "NIE\n"; } return 0; } |