#include <cstdlib>
#include <iostream>
using namespace std;
int min(int T[], int n) {
long long min = 1000000000;
for (int i=0; i < n; i++) {
if (T[i] < min) {
min = T[i];
}
}
return min;
}
int max(int T[], int n) {
long long max = 0;
for (int i=0; i < n; i++) {
if (T[i] > max) {
max = T[i];
}
}
return max;
}
void markTable(int T[], int n, bool result[], int value) {
for (int j = 0; j < n; j++){
if (T[j] == value) {
result[j] = true;
} else {
result[j] = false;
}
}
}
int main() {
int t;
cin >> t;
int n;
for (int i = 0; i < t; i++) {
cin >> n;
int T[4][n];
for (int j = 0; j < n; j++) {
cin >> T[0][j] >> T[1][j] >> T[2][j] >> T[3][j];
}
long long minW1 = min(T[0], n), maxW2 = max(T[1], n),
minH1 = min(T[2], n), maxH2 = max(T[3], n);
bool W1[n], W2[n], H1[n], H2[n];
markTable(T[0], n, W1, minW1);
markTable(T[1], n, W2, maxW2);
markTable(T[2], n, H1, minH1);
markTable(T[3], n, H2, maxH2);
bool exists = false;
for (int j = 0; j < n; j++){
if (W1[j] && W2[j] && H1[j] && H2[j]){
exists = true;
break;
}
}
if (exists) {
cout << "TAK\n";
} else {
cout << "NIE\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 74 75 76 77 | #include <cstdlib> #include <iostream> using namespace std; int min(int T[], int n) { long long min = 1000000000; for (int i=0; i < n; i++) { if (T[i] < min) { min = T[i]; } } return min; } int max(int T[], int n) { long long max = 0; for (int i=0; i < n; i++) { if (T[i] > max) { max = T[i]; } } return max; } void markTable(int T[], int n, bool result[], int value) { for (int j = 0; j < n; j++){ if (T[j] == value) { result[j] = true; } else { result[j] = false; } } } int main() { int t; cin >> t; int n; for (int i = 0; i < t; i++) { cin >> n; int T[4][n]; for (int j = 0; j < n; j++) { cin >> T[0][j] >> T[1][j] >> T[2][j] >> T[3][j]; } long long minW1 = min(T[0], n), maxW2 = max(T[1], n), minH1 = min(T[2], n), maxH2 = max(T[3], n); bool W1[n], W2[n], H1[n], H2[n]; markTable(T[0], n, W1, minW1); markTable(T[1], n, W2, maxW2); markTable(T[2], n, H1, minH1); markTable(T[3], n, H2, maxH2); bool exists = false; for (int j = 0; j < n; j++){ if (W1[j] && W2[j] && H1[j] && H2[j]){ exists = true; break; } } if (exists) { cout << "TAK\n"; } else { cout << "NIE\n"; } } return 0; } |
English