#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char** argv) { ios_base::sync_with_stdio(0); int t; cin >> t; int n; for (int i=0; i<t; i++){ cin >> n; //wczytanie danych int tab[n+1][5]; for (int j=0; j<n; j++){ //w1 w2 h1 h2 cin >> tab[j][0] >> tab[j][1] >> tab[j][2] >> tab[j][3]; } //obliczenie min wartosci z w1 long long min = 1000000000; bool w1[n+1]; for (int j=0; j<n; j++){ w1[j] = false; } for (int j=0; j<n; j++){ if (tab[j][0] < min) min = tab[j][0]; } for (int j=0; j<n; j++){ if (tab[j][0] == min) w1[j] = true; } //obliczenie max wartosci z w2 long long max = 0; bool w2[n+1]; for (int j=0; j<n; j++){ w2[j] = false; } for (int j=0; j<n; j++){ if (tab[j][1] > max) max = tab[j][1]; } for (int j=0; j<n; j++){ if (tab[j][1] == max) w2[j] = true; } //obliczenie min wartosci z h1 min = 1000000000; bool h1[n+1]; for (int j=0; j<n; j++){ h1[j] = false; } for (int j=0; j<n; j++){ if (tab[j][2] < min) min = tab[j][2]; } for (int j=0; j<n; j++){ if (tab[j][2] == min) h1[j] = true; } //obliczenie max wartosci z h2 max = 0; bool h2[n+1]; for (int j=0; j<n; j++){ h2[j] = false; } for (int j=0; j<n; j++){ if (tab[j][3] > max) max = tab[j][3]; } for (int j=0; j<n; j++){ if (tab[j][3] == max) h2[j] = true; } bool istnieje = false; for (int j=0; j<n; j++){ if (w1[j] && w2[j] && h1[j] && h2[j]){ istnieje = true; break; } } if (istnieje) 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char** argv) { ios_base::sync_with_stdio(0); int t; cin >> t; int n; for (int i=0; i<t; i++){ cin >> n; //wczytanie danych int tab[n+1][5]; for (int j=0; j<n; j++){ //w1 w2 h1 h2 cin >> tab[j][0] >> tab[j][1] >> tab[j][2] >> tab[j][3]; } //obliczenie min wartosci z w1 long long min = 1000000000; bool w1[n+1]; for (int j=0; j<n; j++){ w1[j] = false; } for (int j=0; j<n; j++){ if (tab[j][0] < min) min = tab[j][0]; } for (int j=0; j<n; j++){ if (tab[j][0] == min) w1[j] = true; } //obliczenie max wartosci z w2 long long max = 0; bool w2[n+1]; for (int j=0; j<n; j++){ w2[j] = false; } for (int j=0; j<n; j++){ if (tab[j][1] > max) max = tab[j][1]; } for (int j=0; j<n; j++){ if (tab[j][1] == max) w2[j] = true; } //obliczenie min wartosci z h1 min = 1000000000; bool h1[n+1]; for (int j=0; j<n; j++){ h1[j] = false; } for (int j=0; j<n; j++){ if (tab[j][2] < min) min = tab[j][2]; } for (int j=0; j<n; j++){ if (tab[j][2] == min) h1[j] = true; } //obliczenie max wartosci z h2 max = 0; bool h2[n+1]; for (int j=0; j<n; j++){ h2[j] = false; } for (int j=0; j<n; j++){ if (tab[j][3] > max) max = tab[j][3]; } for (int j=0; j<n; j++){ if (tab[j][3] == max) h2[j] = true; } bool istnieje = false; for (int j=0; j<n; j++){ if (w1[j] && w2[j] && h1[j] && h2[j]){ istnieje = true; break; } } if (istnieje) cout << "TAK\n"; else cout << "NIE\n"; } return 0; } |