#include <cstdio>
#include <set>
const int MAXN = 101010;
using namespace std;
struct T {
int h1, h2, w1, w2;
} a[MAXN];
int n;
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int qwe;
scanf("%d", &qwe);
while (qwe--) {
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d%d%d%d", &a[i].h1, &a[i].h2, &a[i].w1, &a[i].w2);
set<int> s;
int min_height = a[0].h1;
for (int i = 1; i < n; i++)
if (min_height > a[i].h1)
min_height = a[i].h1;
// printf("min_height: %d\n", min_height);
for (int i = 0; i < n; i++)
if (a[i].h1 == min_height)
s.insert(i);
int max_height = a[0].h2;
for (int i = 1; i < n; i++)
if (max_height < a[i].h2)
max_height = a[i].h2;
// printf("max_height: %d\n", max_height);
for (set<int>::iterator it = s.begin(); it != s.end(); it++)
if (a[*it].h2 != max_height)
s.erase(it);
if (s.empty()) {
printf("NIE\n");
continue;
}
int min_width = a[0].w1;
for (int i = 1; i < n; i++)
if (min_width > a[i].w1)
min_width = a[i].w1;
// printf("min_width: %d\n", min_width);
for (set<int>::iterator it = s.begin(); it != s.end(); it++)
if (a[*it].w1 != min_width)
s.erase(it);
if (s.empty()) {
printf("NIE\n");
continue;
}
int max_width = a[0].w2;
for (int i = 1; i < n; i++)
if (max_width < a[i].w2)
max_width = a[i].w2;
// printf("max_width: %d\n", max_width);
for (set<int>::iterator it = s.begin(); it != s.end(); it++)
if (a[*it].w2 != max_width)
s.erase(it);
if (s.empty())
printf("NIE\n");
else
printf("TAK\n");
}
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include <cstdio> #include <set> const int MAXN = 101010; using namespace std; struct T { int h1, h2, w1, w2; } a[MAXN]; int n; int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int qwe; scanf("%d", &qwe); while (qwe--) { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d%d%d%d", &a[i].h1, &a[i].h2, &a[i].w1, &a[i].w2); set<int> s; int min_height = a[0].h1; for (int i = 1; i < n; i++) if (min_height > a[i].h1) min_height = a[i].h1; // printf("min_height: %d\n", min_height); for (int i = 0; i < n; i++) if (a[i].h1 == min_height) s.insert(i); int max_height = a[0].h2; for (int i = 1; i < n; i++) if (max_height < a[i].h2) max_height = a[i].h2; // printf("max_height: %d\n", max_height); for (set<int>::iterator it = s.begin(); it != s.end(); it++) if (a[*it].h2 != max_height) s.erase(it); if (s.empty()) { printf("NIE\n"); continue; } int min_width = a[0].w1; for (int i = 1; i < n; i++) if (min_width > a[i].w1) min_width = a[i].w1; // printf("min_width: %d\n", min_width); for (set<int>::iterator it = s.begin(); it != s.end(); it++) if (a[*it].w1 != min_width) s.erase(it); if (s.empty()) { printf("NIE\n"); continue; } int max_width = a[0].w2; for (int i = 1; i < n; i++) if (max_width < a[i].w2) max_width = a[i].w2; // printf("max_width: %d\n", max_width); for (set<int>::iterator it = s.begin(); it != s.end(); it++) if (a[*it].w2 != max_width) s.erase(it); if (s.empty()) printf("NIE\n"); else printf("TAK\n"); } return 0; } |
English