#include <iostream> #include <vector> #include <cstdio> using namespace std; int main() { int T; scanf("%d", &T); while (T--) { int N; cin >> N; vector<int> minw(N), maxw(N), minh(N), maxh(N); int gminw = 2000000000, gmaxw = 0; int gminh = 2000000000, gmaxh = 0; for (int i = 0; i < N; ++i) { scanf("%d%d%d%d", &minw[i], &maxw[i], &minh[i], &maxh[i]); // cin >> minw[i] >> maxw[i] >> minh[i] >> maxh[i]; gminw = min(minw[i], gminw); gmaxw = max(maxw[i], gmaxw); gminh = min(minh[i], gminh); gmaxh = max(maxh[i], gmaxh); } bool major = false; for (int i = 0; i < N; ++i) { if (gminw == minw[i] && gmaxw == maxw[i] && gminh == minh[i] && gmaxh == maxh[i]) { major = true; break; } } /* for (int i = 0; i < N; ++i) { int iminw = minw[i]; int imaxw = maxw[i]; int iminh = minh[i]; int imaxh = maxh[i]; bool thismajor = true; for (int k = 0; k < N; ++k) { if (i == k) continue; int kminw = minw[k]; int kmaxw = maxw[k]; int kminh = minh[k]; int kmaxh = maxh[k]; thismajor &= iminw <= kminw && imaxw >= kmaxw && iminh <= kminh && imaxh >= kmaxh; if (!thismajor) break; } major |= thismajor; }*/ printf("%s\n", major ? "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 | #include <iostream> #include <vector> #include <cstdio> using namespace std; int main() { int T; scanf("%d", &T); while (T--) { int N; cin >> N; vector<int> minw(N), maxw(N), minh(N), maxh(N); int gminw = 2000000000, gmaxw = 0; int gminh = 2000000000, gmaxh = 0; for (int i = 0; i < N; ++i) { scanf("%d%d%d%d", &minw[i], &maxw[i], &minh[i], &maxh[i]); // cin >> minw[i] >> maxw[i] >> minh[i] >> maxh[i]; gminw = min(minw[i], gminw); gmaxw = max(maxw[i], gmaxw); gminh = min(minh[i], gminh); gmaxh = max(maxh[i], gmaxh); } bool major = false; for (int i = 0; i < N; ++i) { if (gminw == minw[i] && gmaxw == maxw[i] && gminh == minh[i] && gmaxh == maxh[i]) { major = true; break; } } /* for (int i = 0; i < N; ++i) { int iminw = minw[i]; int imaxw = maxw[i]; int iminh = minh[i]; int imaxh = maxh[i]; bool thismajor = true; for (int k = 0; k < N; ++k) { if (i == k) continue; int kminw = minw[k]; int kmaxw = maxw[k]; int kminh = minh[k]; int kmaxh = maxh[k]; thismajor &= iminw <= kminw && imaxw >= kmaxw && iminh <= kminh && imaxh >= kmaxh; if (!thismajor) break; } major |= thismajor; }*/ printf("%s\n", major ? "TAK" : "NIE"); } } |