#include <cstdio> #include <cstdlib> using namespace std; int t, n; int w1[100000], w2[100000], h1[100000], h2[100000]; int min_w, max_w, min_h, max_h; int main(int argc, char *argv[]) { scanf("%d", &t); while(--t >= 0) { scanf("%d", &n); scanf("%d%d%d%d", &w1[0], &w2[0], &h1[0], &h2[0]); min_w = w1[0]; max_w = w2[0]; min_h = h1[0]; max_h = h2[0]; for(int i=1; i<n; i++) { scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]); if (w1[i] < min_w) min_w = w1[i]; if (w2[i] > max_w) max_w = w2[i]; if (h1[i] < min_h) min_h = h1[i]; if (h2[i] > max_h) max_h = h2[i]; } bool nie = true; for(int i=0; i<n; i++) { if (w1[i] == min_w && w2[i] == max_w && h1[i] == min_h && h2[i] == max_h) { printf("TAK\n"); nie = false; break; } } if (nie) 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 49 50 51 | #include <cstdio> #include <cstdlib> using namespace std; int t, n; int w1[100000], w2[100000], h1[100000], h2[100000]; int min_w, max_w, min_h, max_h; int main(int argc, char *argv[]) { scanf("%d", &t); while(--t >= 0) { scanf("%d", &n); scanf("%d%d%d%d", &w1[0], &w2[0], &h1[0], &h2[0]); min_w = w1[0]; max_w = w2[0]; min_h = h1[0]; max_h = h2[0]; for(int i=1; i<n; i++) { scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]); if (w1[i] < min_w) min_w = w1[i]; if (w2[i] > max_w) max_w = w2[i]; if (h1[i] < min_h) min_h = h1[i]; if (h2[i] > max_h) max_h = h2[i]; } bool nie = true; for(int i=0; i<n; i++) { if (w1[i] == min_w && w2[i] == max_w && h1[i] == min_h && h2[i] == max_h) { printf("TAK\n"); nie = false; break; } } if (nie) printf("NIE\n"); } return 0; } |