#include <stdio.h> #include <stdlib.h> int main() { int i, j, t, n, w1, w2, h1, h2, w_min, w_max, h_min, h_max, jest; char odp[2][4] = {"NIE", "TAK"}; scanf("%d", &t); for (i = 0; i < t; i++) { scanf("%d", &n); scanf("%d%d%d%d", &w_min, &w_max, &h_min, &h_max); for (jest = j = 1; j < n; j++) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); if (w1 <= w_min && w2 >= w_max && h1 <= h_min && h2 >= h_max) { jest = 1; w_min = w1; w_max = w2; h_min = h1; h_max = h2; } else if (w1 < w_min || w2 > w_max || h1 < h_min || h2 > h_max) { jest = 0; if (w1 < w_min) w_min = w1; if (w2 > w_max) w_max = w2; if (h1 < h_min) h_min = h1; if (h2 > h_max) h_max = h2; } } printf("%s\n", odp[jest]); } 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 <stdio.h> #include <stdlib.h> int main() { int i, j, t, n, w1, w2, h1, h2, w_min, w_max, h_min, h_max, jest; char odp[2][4] = {"NIE", "TAK"}; scanf("%d", &t); for (i = 0; i < t; i++) { scanf("%d", &n); scanf("%d%d%d%d", &w_min, &w_max, &h_min, &h_max); for (jest = j = 1; j < n; j++) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); if (w1 <= w_min && w2 >= w_max && h1 <= h_min && h2 >= h_max) { jest = 1; w_min = w1; w_max = w2; h_min = h1; h_max = h2; } else if (w1 < w_min || w2 > w_max || h1 < h_min || h2 > h_max) { jest = 0; if (w1 < w_min) w_min = w1; if (w2 > w_max) w_max = w2; if (h1 < h_min) h_min = h1; if (h2 > h_max) h_max = h2; } } printf("%s\n", odp[jest]); } return 0; } |