#include <cstdio> #include <algorithm> #define scanf(args...) (scanf(args) ? : 0) const int MAXN = 1e5+5; const int INF = 1e9+5; struct Company { int w1, w2, h1, h2; } T[MAXN]; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); int minw = INF, maxw = 0, minh = INF, maxh = 0; for (int i=0; i<n; i++) { scanf("%d%d%d%d", &T[i].w1, &T[i].w2, &T[i].h1, &T[i].h2); minw = std::min(minw, T[i].w1); maxw = std::max(maxw, T[i].w2); minh = std::min(minh, T[i].h1); maxh = std::max(maxh, T[i].h2); } bool found = false; for (int i=0; i<n && !found; i++) { if (T[i].w1 == minw && T[i].w2 == maxw) if (T[i].h1 == minh && T[i].h2 == maxh) found = true; } printf("%s\n", found ? "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 | #include <cstdio> #include <algorithm> #define scanf(args...) (scanf(args) ? : 0) const int MAXN = 1e5+5; const int INF = 1e9+5; struct Company { int w1, w2, h1, h2; } T[MAXN]; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); int minw = INF, maxw = 0, minh = INF, maxh = 0; for (int i=0; i<n; i++) { scanf("%d%d%d%d", &T[i].w1, &T[i].w2, &T[i].h1, &T[i].h2); minw = std::min(minw, T[i].w1); maxw = std::max(maxw, T[i].w2); minh = std::min(minh, T[i].h1); maxh = std::max(maxh, T[i].h2); } bool found = false; for (int i=0; i<n && !found; i++) { if (T[i].w1 == minw && T[i].w2 == maxw) if (T[i].h1 == minh && T[i].h2 == maxh) found = true; } printf("%s\n", found ? "TAK" : "NIE"); } } |