#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <limits> #include <climits> #include <map> #include <set> const long long LLMAX = (std::numeric_limits<long long>()).max(); const long long LLMIN = (std::numeric_limits<long long>()).min(); int main() { std::ios_base::sync_with_stdio(false); int t; scanf("%d", &t); for (int it=0; it < t; ++it) { int wmin = INT_MAX; int wmax = 0; int hmin = INT_MAX; int hmax = 0; bool majFound = false; int n; scanf("%d", &n); for (int in=0; in < n; ++in) { int w1, w2, h1, h2; scanf("%d %d %d %d", &w1, &w2, &h1, &h2); bool expanded = false; if (wmin > w1) { wmin = w1; expanded = true; } if (wmax < w2) { wmax = w2; expanded = true; } if (hmin > h1) { hmin = h1; expanded = true; } if (hmax < h2) { hmax = h2; expanded = true; } if (expanded) { if ( wmin == w1 && wmax == w2 && hmin == h1 && hmax == h2 ) { majFound = true; } else { majFound = false; } } else if (!majFound) { if ( wmin == w1 && wmax == w2 && hmin == h1 && hmax == h2 ) { majFound = true; } } } printf("%s\n", (majFound) ? "TAK" : "NIE"); } }
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 71 | #include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <limits> #include <climits> #include <map> #include <set> const long long LLMAX = (std::numeric_limits<long long>()).max(); const long long LLMIN = (std::numeric_limits<long long>()).min(); int main() { std::ios_base::sync_with_stdio(false); int t; scanf("%d", &t); for (int it=0; it < t; ++it) { int wmin = INT_MAX; int wmax = 0; int hmin = INT_MAX; int hmax = 0; bool majFound = false; int n; scanf("%d", &n); for (int in=0; in < n; ++in) { int w1, w2, h1, h2; scanf("%d %d %d %d", &w1, &w2, &h1, &h2); bool expanded = false; if (wmin > w1) { wmin = w1; expanded = true; } if (wmax < w2) { wmax = w2; expanded = true; } if (hmin > h1) { hmin = h1; expanded = true; } if (hmax < h2) { hmax = h2; expanded = true; } if (expanded) { if ( wmin == w1 && wmax == w2 && hmin == h1 && hmax == h2 ) { majFound = true; } else { majFound = false; } } else if (!majFound) { if ( wmin == w1 && wmax == w2 && hmin == h1 && hmax == h2 ) { majFound = true; } } } printf("%s\n", (majFound) ? "TAK" : "NIE"); } } |