#include <cstdio>
#include <climits>
bool majorizes() {
const int maxn = 100001;
int n;
scanf("%d", &n);
int mw1 = INT_MAX, mw2 = 0, mh1 = INT_MAX, mh2 = 0;
int w1[maxn], w2[maxn], h1[maxn], h2[maxn];
for (int i = 0; i < n; ++i) {
scanf("%d %d %d %d", w1+i, w2+i, h1+i, h2+i);
if (w1[i] <= mw1 && w2[i] >= mw2 && h1[i] <= mh1 && h2[i] >= mh2) {
mw1 = w1[i];
mw2 = w2[i];
mh1 = h1[i];
mh2 = h2[i];
}
}
for (int i = 0; i < n; ++i) {
if (w1[i] < mw1 || w2[i] > mw2 || h1[i] < mh1 || h2[i] > mh2)
return false;
}
return true;
}
int main(int argc, char *argv[]) {
int tests;
scanf("%d", &tests);
for (int t = 0; t < tests; ++t) {
if (majorizes()) {
puts("TAK");
} else {
puts("NIE");
}
}
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 | #include <cstdio> #include <climits> bool majorizes() { const int maxn = 100001; int n; scanf("%d", &n); int mw1 = INT_MAX, mw2 = 0, mh1 = INT_MAX, mh2 = 0; int w1[maxn], w2[maxn], h1[maxn], h2[maxn]; for (int i = 0; i < n; ++i) { scanf("%d %d %d %d", w1+i, w2+i, h1+i, h2+i); if (w1[i] <= mw1 && w2[i] >= mw2 && h1[i] <= mh1 && h2[i] >= mh2) { mw1 = w1[i]; mw2 = w2[i]; mh1 = h1[i]; mh2 = h2[i]; } } for (int i = 0; i < n; ++i) { if (w1[i] < mw1 || w2[i] > mw2 || h1[i] < mh1 || h2[i] > mh2) return false; } return true; } int main(int argc, char *argv[]) { int tests; scanf("%d", &tests); for (int t = 0; t < tests; ++t) { if (majorizes()) { puts("TAK"); } else { puts("NIE"); } } return 0; } |
English