#include <cstdio> #include <vector> #include <map> #include <algorithm> #include <set> #include <deque> #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) using namespace std; struct X { int w1, w2, h1, h2; void get() { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); } void update(const X& x) { w1 = min(w1, x.w1); w2 = max(w2, x.w2); h1 = min(h1, x.h1); h2 = max(h2, x.h2); } bool operator==(const X& x) const { return (w1 == x.w1) and (w2 == x.w2) and (h1 == x.h1) and (h2 == x.h2); } }; void fun() { int n; scanf("%d", &n); vector<X> d(n); REP(i, n) d[i].get(); X best = d[0]; REP(i, n) best.update(d[i]); REP(i, n) if (best == d[i]) { printf("TAK\n"); return; } printf("NIE\n"); } int main() { int t; scanf("%d", &t); REP(i, t) fun(); 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 | #include <cstdio> #include <vector> #include <map> #include <algorithm> #include <set> #include <deque> #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) using namespace std; struct X { int w1, w2, h1, h2; void get() { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); } void update(const X& x) { w1 = min(w1, x.w1); w2 = max(w2, x.w2); h1 = min(h1, x.h1); h2 = max(h2, x.h2); } bool operator==(const X& x) const { return (w1 == x.w1) and (w2 == x.w2) and (h1 == x.h1) and (h2 == x.h2); } }; void fun() { int n; scanf("%d", &n); vector<X> d(n); REP(i, n) d[i].get(); X best = d[0]; REP(i, n) best.update(d[i]); REP(i, n) if (best == d[i]) { printf("TAK\n"); return; } printf("NIE\n"); } int main() { int t; scanf("%d", &t); REP(i, t) fun(); return 0; } |