#include <cstdio> typedef long long ll; int main() { int t; scanf("%d", &t); for (int tt = 0; tt < t; ++tt) { int n; scanf("%d", &n); bool major = true; int minWidth = 1e9; int maxWidth = 0; int minHeight = 1e9; int maxHeight = 0; for (int i = 0; i < n; ++i) { int w1, w2, h1, h2; scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if (w1 <= minWidth && w2 >= maxWidth && h1 <= minHeight && h2 >= maxHeight) { minWidth = w1; maxWidth = w2; minHeight = h1; maxHeight = h2; major = true; } else { if (w1 < minWidth) { minWidth = w1; major = false; } if (w2 > maxWidth) { maxWidth = w2; major = false; } if (h1 < minHeight) { minHeight = h1; major = false; } if (h2 > maxHeight) { maxHeight = h2; major = false; } } } if (major) { printf("TAK\n"); } else { 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 52 53 54 55 56 57 58 59 60 | #include <cstdio> typedef long long ll; int main() { int t; scanf("%d", &t); for (int tt = 0; tt < t; ++tt) { int n; scanf("%d", &n); bool major = true; int minWidth = 1e9; int maxWidth = 0; int minHeight = 1e9; int maxHeight = 0; for (int i = 0; i < n; ++i) { int w1, w2, h1, h2; scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if (w1 <= minWidth && w2 >= maxWidth && h1 <= minHeight && h2 >= maxHeight) { minWidth = w1; maxWidth = w2; minHeight = h1; maxHeight = h2; major = true; } else { if (w1 < minWidth) { minWidth = w1; major = false; } if (w2 > maxWidth) { maxWidth = w2; major = false; } if (h1 < minHeight) { minHeight = h1; major = false; } if (h2 > maxHeight) { maxHeight = h2; major = false; } } } if (major) { printf("TAK\n"); } else { printf("NIE\n"); } } return 0; } |