#include <cstdio>
#include <vector>
using namespace std;
int where[ 100005 ], liczby[ 100005 ][ 4 ];
int main(){
int t;
scanf("%d",&t);
while (t--){
int n;
scanf("%d",&n);
for (int i = 0; i < n; i++){
for (int j = 0; j < 4; j++){
scanf("%d",&liczby[i][j]);
}
}
for (int i = 0; i < 2; i++){
int mini = 2000000002, maxi = 0;
for (int j = 0; j < n; j++){
if (liczby[ j ][ 2*i ] < mini){
mini = liczby[ j ][ 2*i ];
}
}
for (int j = 0; j < n; j++){
if (liczby[ j ][ 2*i ] == mini){
where[ j ]++;
}
}
for (int j = 0; j < n; j++){
if (liczby[ j ][ 2*i+1 ] > maxi){
maxi = liczby[ j ][ 2*i+1 ];
}
}
for (int j = 0; j < n; j++){
if (liczby[ j ][ 2*i+1 ] == maxi){
where[ j ]++;
}
}
}
bool exist = false;
for (int i = 0; i < n; i++){
if (where[i] == 4){
exist = true;
break;
}
}
if (exist){
printf("TAK\n");
}
else {
printf("NIE\n");
}
for (int i = 0; i < n; i++){
where[ i ] = 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> using namespace std; int where[ 100005 ], liczby[ 100005 ][ 4 ]; int main(){ int t; scanf("%d",&t); while (t--){ int n; scanf("%d",&n); for (int i = 0; i < n; i++){ for (int j = 0; j < 4; j++){ scanf("%d",&liczby[i][j]); } } for (int i = 0; i < 2; i++){ int mini = 2000000002, maxi = 0; for (int j = 0; j < n; j++){ if (liczby[ j ][ 2*i ] < mini){ mini = liczby[ j ][ 2*i ]; } } for (int j = 0; j < n; j++){ if (liczby[ j ][ 2*i ] == mini){ where[ j ]++; } } for (int j = 0; j < n; j++){ if (liczby[ j ][ 2*i+1 ] > maxi){ maxi = liczby[ j ][ 2*i+1 ]; } } for (int j = 0; j < n; j++){ if (liczby[ j ][ 2*i+1 ] == maxi){ where[ j ]++; } } } bool exist = false; for (int i = 0; i < n; i++){ if (where[i] == 4){ exist = true; break; } } if (exist){ printf("TAK\n"); } else { printf("NIE\n"); } for (int i = 0; i < n; i++){ where[ i ] = 0; } } } |
English