#include <cstdio> //:D #define INFINITY 2000000000 int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); int w1, w2, h1, h2; bool itis = false; int minW1 = INFINITY; int maxW2 = -1; int minH1 = INFINITY; int maxH2 = -1; while (n--) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); bool allInside = true; bool allOutside = true; if (w1 < minW1) { minW1 = w1; allInside = false; } else if (w1 > minW1) allOutside = false; if (w2 > maxW2) { maxW2 = w2; allInside = false; } else if (w2 < maxW2) allOutside = false; if (h1 < minH1) { minH1 = h1; allInside = false; } else if (h1 > minH1) allOutside = false; if (h2 > maxH2) { maxH2 = h2; allInside = false; } else if (h2 < maxH2) allOutside = false; if (allOutside) itis = true; else if (!allInside) itis = false; } if (itis) 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 61 62 63 64 65 66 67 68 69 70 | #include <cstdio> //:D #define INFINITY 2000000000 int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); int w1, w2, h1, h2; bool itis = false; int minW1 = INFINITY; int maxW2 = -1; int minH1 = INFINITY; int maxH2 = -1; while (n--) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); bool allInside = true; bool allOutside = true; if (w1 < minW1) { minW1 = w1; allInside = false; } else if (w1 > minW1) allOutside = false; if (w2 > maxW2) { maxW2 = w2; allInside = false; } else if (w2 < maxW2) allOutside = false; if (h1 < minH1) { minH1 = h1; allInside = false; } else if (h1 > minH1) allOutside = false; if (h2 > maxH2) { maxH2 = h2; allInside = false; } else if (h2 < maxH2) allOutside = false; if (allOutside) itis = true; else if (!allInside) itis = false; } if (itis) printf("TAK\n"); else printf("NIE\n"); } return 0; } |