#include <cstdio> using namespace std; int main() { int t; scanf("%d", &t); for(int i=0; i<t; i++) { int n, wmin=1000000001, wmax=0, hmin=1000000001, hmax=0; bool majority=false; scanf("%d", &n); for(int j=0; j<n; j++) { int w1, w2, h1, h2; scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if(h2>=hmax&&h1<=hmin&&w2>=wmax&&w1<=wmin) { majority=true; hmin=h1; hmax=h2; wmin=w1; wmax=w2; } else { if(w1 < wmin) wmin=w1, majority=false; if(w2 > wmax) wmax=w2, majority=false; if(h1 < hmin) hmin=h1, majority=false; if(h2 > hmax) hmax=h2, majority=false; } } if(majority) puts("TAK"); else puts("NIE"); } 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 | #include <cstdio> using namespace std; int main() { int t; scanf("%d", &t); for(int i=0; i<t; i++) { int n, wmin=1000000001, wmax=0, hmin=1000000001, hmax=0; bool majority=false; scanf("%d", &n); for(int j=0; j<n; j++) { int w1, w2, h1, h2; scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if(h2>=hmax&&h1<=hmin&&w2>=wmax&&w1<=wmin) { majority=true; hmin=h1; hmax=h2; wmin=w1; wmax=w2; } else { if(w1 < wmin) wmin=w1, majority=false; if(w2 > wmax) wmax=w2, majority=false; if(h1 < hmin) hmin=h1, majority=false; if(h2 > hmax) hmax=h2, majority=false; } } if(majority) puts("TAK"); else puts("NIE"); } return 0; } |