#include <cstdio> using namespace std; int t,n,w1,w2,h1,h2; int w_min, w_max, h_min, h_max; int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); bool r = true; w_max = h_max = -1; w_min = h_min = 1 << 30; for(int i = 0; i<n ; i++) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if ( w1 <= w_min && w2 >= w_max && h1 <= h_min && h2 >= h_max ) { w_min = w1; w_max = w2; h_min = h1; h_max = h2; r = true; } else { if ( w1 < w_min) { w_min = w1; r = false; } if ( w2 > w_max) { w_max = w2; r = false; } if ( h1 < h_min) { h_min = h1; r = false; } if ( h2 > h_max) { h_max = h2; r = false; } } // printf("wmin:%d wmax:%d hmin:%d hmax:%d \n", w_min, w_max, h_min, h_max); } r ? printf("TAK\n") : printf("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 38 39 40 41 42 43 44 45 46 47 48 | #include <cstdio> using namespace std; int t,n,w1,w2,h1,h2; int w_min, w_max, h_min, h_max; int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); bool r = true; w_max = h_max = -1; w_min = h_min = 1 << 30; for(int i = 0; i<n ; i++) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if ( w1 <= w_min && w2 >= w_max && h1 <= h_min && h2 >= h_max ) { w_min = w1; w_max = w2; h_min = h1; h_max = h2; r = true; } else { if ( w1 < w_min) { w_min = w1; r = false; } if ( w2 > w_max) { w_max = w2; r = false; } if ( h1 < h_min) { h_min = h1; r = false; } if ( h2 > h_max) { h_max = h2; r = false; } } // printf("wmin:%d wmax:%d hmin:%d hmax:%d \n", w_min, w_max, h_min, h_max); } r ? printf("TAK\n") : printf("NIE\n"); } return 0; } |