#include <cstdio> int t, n, h1[100000], h2[100000], w1[100000], w2[100000], hmin, hmax, wmin, wmax; int main() { scanf("%d", &t); while(t--) { hmax = 0; wmax = 0; hmin = 1000000000; wmin = 1000000000; scanf("%d", &n); for (int i = 0 ; i < n; i++) { scanf("%d%d%d%d",&h1[i], &h2[i], &w1[i], &w2[i]); if (h1[i] < hmin) hmin = h1[i]; if (h2[i] > hmax) hmax = h2[i]; if (w1[i] < wmin) wmin = w1[i]; if (w2[i] > wmax) wmax = w2[i]; } for (int i = 0; i < n; i++) { if (hmin == h1[i] and hmax == h2[i] and wmin == w1[i] and wmax == w2[i]) { printf("TAK \n"); break; } if (i == n-1) 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 | #include <cstdio> int t, n, h1[100000], h2[100000], w1[100000], w2[100000], hmin, hmax, wmin, wmax; int main() { scanf("%d", &t); while(t--) { hmax = 0; wmax = 0; hmin = 1000000000; wmin = 1000000000; scanf("%d", &n); for (int i = 0 ; i < n; i++) { scanf("%d%d%d%d",&h1[i], &h2[i], &w1[i], &w2[i]); if (h1[i] < hmin) hmin = h1[i]; if (h2[i] > hmax) hmax = h2[i]; if (w1[i] < wmin) wmin = w1[i]; if (w2[i] > wmax) wmax = w2[i]; } for (int i = 0; i < n; i++) { if (hmin == h1[i] and hmax == h2[i] and wmin == w1[i] and wmax == w2[i]) { printf("TAK \n"); break; } if (i == n-1) printf("NIE \n"); } } return 0; } |