#include <cstdio> #include <vector> #include <algorithm> using namespace std; struct okno { int w1, w2; int h1, h2; int wd() const { return w2 - w1; } int hd() const { return h2 - h1; } bool operator < (const okno& o) const { if (wd() != o.wd()) return wd() > o.wd(); if (hd() != o.hd()) return hd() > o.hd(); return false; } bool dominates(const okno& o) const { return w1 <= o.w1 && w2 >= o.w2 && h1 <= o.h1 && h2 >= o.h2; } }; void testCase() { int n; scanf("%i", &n); std::vector<okno> okna; for (int i = 0; i < n; ++i) { okno o; scanf("%i %i %i %i", &o.w1, &o.w2, &o.h1, &o.h2); okna.push_back(o); } sort(okna.begin(), okna.end()); bool ok = true; for (int i = 1; i < okna.size(); ++i) { if (!okna[0].dominates(okna[i])) { ok = false; break; } } puts(ok ? "TAK" : "NIE"); } int main() { int t; scanf("%i", &t); for (int i = 0; i < t; ++i) { testCase(); } 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 | #include <cstdio> #include <vector> #include <algorithm> using namespace std; struct okno { int w1, w2; int h1, h2; int wd() const { return w2 - w1; } int hd() const { return h2 - h1; } bool operator < (const okno& o) const { if (wd() != o.wd()) return wd() > o.wd(); if (hd() != o.hd()) return hd() > o.hd(); return false; } bool dominates(const okno& o) const { return w1 <= o.w1 && w2 >= o.w2 && h1 <= o.h1 && h2 >= o.h2; } }; void testCase() { int n; scanf("%i", &n); std::vector<okno> okna; for (int i = 0; i < n; ++i) { okno o; scanf("%i %i %i %i", &o.w1, &o.w2, &o.h1, &o.h2); okna.push_back(o); } sort(okna.begin(), okna.end()); bool ok = true; for (int i = 1; i < okna.size(); ++i) { if (!okna[0].dominates(okna[i])) { ok = false; break; } } puts(ok ? "TAK" : "NIE"); } int main() { int t; scanf("%i", &t); for (int i = 0; i < t; ++i) { testCase(); } return 0; } |