#include <cstdio> #define maxn 100000 struct Vertex { int w1, w2, h1, h2; Vertex(int a, int b, int c, int d): w1(a), w2(b), h1(c), h2(d) {} Vertex() {} } t[maxn]; bool v[maxn]; bool edge(Vertex u, Vertex v) { return (u.w1 <= v.w1) && (v.w2 <= u.w2) && (u.h1 <= v.h1) && (v.h2 <= u.h2); } void solve() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); t[i] = Vertex(a, b, c, d); v[i] = false; } for (int i = 0; i < n; i++) if (!v[i]) { for (int j = 0; j < n; j++) if (i != j) { if (edge(t[i], t[j])) { v[j] = true; } else { v[i] = true; break; } } } bool result = false; for (int i = 0; i < n; i++) if (!v[i]) { result = true; break; } printf(result ? "TAK\n" : "NIE\n"); } int main() { int z; scanf("%d", &z); while (z--) solve(); 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 | #include <cstdio> #define maxn 100000 struct Vertex { int w1, w2, h1, h2; Vertex(int a, int b, int c, int d): w1(a), w2(b), h1(c), h2(d) {} Vertex() {} } t[maxn]; bool v[maxn]; bool edge(Vertex u, Vertex v) { return (u.w1 <= v.w1) && (v.w2 <= u.w2) && (u.h1 <= v.h1) && (v.h2 <= u.h2); } void solve() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); t[i] = Vertex(a, b, c, d); v[i] = false; } for (int i = 0; i < n; i++) if (!v[i]) { for (int j = 0; j < n; j++) if (i != j) { if (edge(t[i], t[j])) { v[j] = true; } else { v[i] = true; break; } } } bool result = false; for (int i = 0; i < n; i++) if (!v[i]) { result = true; break; } printf(result ? "TAK\n" : "NIE\n"); } int main() { int z; scanf("%d", &z); while (z--) solve(); return 0; } |