#include <cstdio> int main() { int t, n, w1, w2, h1, h2; int w_min, w_max, h_min, h_max; scanf("%d", &t); for (int i=0;i<t;i++) { scanf("%d", &n); w_max = h_max = -1; w_min = h_min = 1000001000; bool result = false; for (int j=0;j<n;j++) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if (w_max < w2) { w_max = w2; result = false; } if (w_min > w1) { w_min = w1; result = false; } if (h_max < h2) { h_max = h2; result = false; } if (h_min > h1) { h_min = h1; result = false; } if (h_min == h1 and h_max == h2 and w_min == w1 and w_max == w2) result = true; } printf("%s\n", result ? "TAK" : "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 | #include <cstdio> int main() { int t, n, w1, w2, h1, h2; int w_min, w_max, h_min, h_max; scanf("%d", &t); for (int i=0;i<t;i++) { scanf("%d", &n); w_max = h_max = -1; w_min = h_min = 1000001000; bool result = false; for (int j=0;j<n;j++) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if (w_max < w2) { w_max = w2; result = false; } if (w_min > w1) { w_min = w1; result = false; } if (h_max < h2) { h_max = h2; result = false; } if (h_min > h1) { h_min = h1; result = false; } if (h_min == h1 and h_max == h2 and w_min == w1 and w_max == w2) result = true; } printf("%s\n", result ? "TAK" : "NIE"); } return 0; } |