#include <cstdio> #include <cassert> #include <unordered_map> #include <algorithm> using namespace std; const int oo = 2000000000; int main() { int zet; assert(scanf("%d", &zet) == 1); while (zet--) { int n; assert(scanf("%d", &n) == 1); bool someone = false; int minW = oo; int maxW = 0; int minH = oo; int maxH = 0; for (int i = 0; i < n; i++) { int w1, w2, h1, h2; assert(scanf("%d %d %d %d", &w1, &w2, &h1, &h2) == 4); if (w1 <= minW && w2 >= maxW && h1 <= minH && h2 >= maxH) { someone = true; } else if (w1 < minW || w2 > maxW || h1 < minH || h2 > maxH) { someone = false; } minW = min(minW, w1); maxW = max(maxW, w2); minH = min(minH, h1); maxH = max(maxH, h2); } if (someone) { 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 | #include <cstdio> #include <cassert> #include <unordered_map> #include <algorithm> using namespace std; const int oo = 2000000000; int main() { int zet; assert(scanf("%d", &zet) == 1); while (zet--) { int n; assert(scanf("%d", &n) == 1); bool someone = false; int minW = oo; int maxW = 0; int minH = oo; int maxH = 0; for (int i = 0; i < n; i++) { int w1, w2, h1, h2; assert(scanf("%d %d %d %d", &w1, &w2, &h1, &h2) == 4); if (w1 <= minW && w2 >= maxW && h1 <= minH && h2 >= maxH) { someone = true; } else if (w1 < minW || w2 > maxW || h1 < minH || h2 > maxH) { someone = false; } minW = min(minW, w1); maxW = max(maxW, w2); minH = min(minH, h1); maxH = max(maxH, h2); } if (someone) { printf("TAK\n"); } else { printf("NIE\n"); } } return 0; } |