#include <cstdio> #include <vector> #include <algorithm> using namespace std; const int MAXN = 1000007; const int GUARD = 1000000007; vector <int> dim[MAXN]; void solve() { int ext[10]; int n; bool major = false; ext[1] = ext[3] = 0; ext[0] = ext[2] = GUARD; scanf("%d", &n); for (int j = 0; j < n; ++j) { for (int k = 0; k < 4; ++k) { int a; scanf("%d", &a); dim[j].push_back(a); if (k % 2 == 0) ext[k] = min(a, ext[k]); else ext[k] = max(a, ext[k]); } } for (int j = 0; j < n; ++j) { if (ext[0] == dim[j][0] && ext[1] == dim[j][1] && ext[2] == dim[j][2] && ext[3] == dim[j][3]) { major = true; break; } } for (int j = 0; j < n; ++j) { dim[j].clear(); } if (major) printf("TAK\n"); else printf("NIE\n"); } int main() { int t; scanf("%d", &t); for (int i = 0; i < t; ++i) { 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 49 50 51 52 53 54 55 56 | #include <cstdio> #include <vector> #include <algorithm> using namespace std; const int MAXN = 1000007; const int GUARD = 1000000007; vector <int> dim[MAXN]; void solve() { int ext[10]; int n; bool major = false; ext[1] = ext[3] = 0; ext[0] = ext[2] = GUARD; scanf("%d", &n); for (int j = 0; j < n; ++j) { for (int k = 0; k < 4; ++k) { int a; scanf("%d", &a); dim[j].push_back(a); if (k % 2 == 0) ext[k] = min(a, ext[k]); else ext[k] = max(a, ext[k]); } } for (int j = 0; j < n; ++j) { if (ext[0] == dim[j][0] && ext[1] == dim[j][1] && ext[2] == dim[j][2] && ext[3] == dim[j][3]) { major = true; break; } } for (int j = 0; j < n; ++j) { dim[j].clear(); } if (major) printf("TAK\n"); else printf("NIE\n"); } int main() { int t; scanf("%d", &t); for (int i = 0; i < t; ++i) { solve(); } return 0; } |