#include <list> #include <iostream> #include <math.h> #include <algorithm> #include <iterator> #include <vector> using namespace std; int main() { int n; cin >> n; for (int i = 0; i< n; i++) { int wynik=0; int d; vector<int> t0, t1, t2, t3; int s0, l1, s2, l3; cin >> d; int tab[d][4]; for (int a = 0; a < d; a++) { for (int b = 0; b < 4; b++){ cin >> tab[a][b]; } } s0=tab[0][0]; for (int a = 0; a < d; a++){ if (tab[a][0] < s0){t0.clear();s0=tab[a][0];} if (tab[a][0] <= s0) { t0.push_back(a) ;} } l1 = tab[0][1]; for (int a = 0; a < d; a++){ if (tab[a][1] > l1) {t1.clear();l1=tab[a][1];} if (tab[a][1] >= l1) { t1.push_back(a) ;} } s2 = tab[0][2]; for (int a = 0; a < d; a++){ if (tab[a][2] < s2) {t2.clear();s2=tab[a][2];} if (tab[a][2] <= s2) { t2.push_back(a) ;} } l3 = tab[0][3]; for (int a = 0; a < d; a++){ if (tab[a][3] > l3) {t3.clear();l3=tab[a][3];} if (tab[a][3] >= l3) { t3.push_back(a) ;} } /* cout<<"t0: "; for(int x=0; x<t0.size(); x++){cout<<t0[x]<<" ";} cout<<"\n"; cout<<"t1: "; for(int x=0; x<t1.size(); x++){cout<<t1[x]<<" ";} cout<<"\n"; cout<<"t2: "; for(int x=0; x<t2.size(); x++){cout<<t2[x]<<" ";} cout<<"\n"; cout<<"t3: "; for(int x=0; x<t3.size(); x++){cout<<t3[x]<<" ";} cout<<"\n";*/ for(int a=0; a<t0.size(); a++) { if(binary_search(t1.begin(), t1.end(),t0[a])){ if(binary_search(t2.begin(), t2.end(), t0[a])){ if(binary_search(t3.begin(), t3.end(), t0[a])){ wynik++; } } } } if(wynik>0)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 | #include <list> #include <iostream> #include <math.h> #include <algorithm> #include <iterator> #include <vector> using namespace std; int main() { int n; cin >> n; for (int i = 0; i< n; i++) { int wynik=0; int d; vector<int> t0, t1, t2, t3; int s0, l1, s2, l3; cin >> d; int tab[d][4]; for (int a = 0; a < d; a++) { for (int b = 0; b < 4; b++){ cin >> tab[a][b]; } } s0=tab[0][0]; for (int a = 0; a < d; a++){ if (tab[a][0] < s0){t0.clear();s0=tab[a][0];} if (tab[a][0] <= s0) { t0.push_back(a) ;} } l1 = tab[0][1]; for (int a = 0; a < d; a++){ if (tab[a][1] > l1) {t1.clear();l1=tab[a][1];} if (tab[a][1] >= l1) { t1.push_back(a) ;} } s2 = tab[0][2]; for (int a = 0; a < d; a++){ if (tab[a][2] < s2) {t2.clear();s2=tab[a][2];} if (tab[a][2] <= s2) { t2.push_back(a) ;} } l3 = tab[0][3]; for (int a = 0; a < d; a++){ if (tab[a][3] > l3) {t3.clear();l3=tab[a][3];} if (tab[a][3] >= l3) { t3.push_back(a) ;} } /* cout<<"t0: "; for(int x=0; x<t0.size(); x++){cout<<t0[x]<<" ";} cout<<"\n"; cout<<"t1: "; for(int x=0; x<t1.size(); x++){cout<<t1[x]<<" ";} cout<<"\n"; cout<<"t2: "; for(int x=0; x<t2.size(); x++){cout<<t2[x]<<" ";} cout<<"\n"; cout<<"t3: "; for(int x=0; x<t3.size(); x++){cout<<t3[x]<<" ";} cout<<"\n";*/ for(int a=0; a<t0.size(); a++) { if(binary_search(t1.begin(), t1.end(),t0[a])){ if(binary_search(t2.begin(), t2.end(), t0[a])){ if(binary_search(t3.begin(), t3.end(), t0[a])){ wynik++; } } } } if(wynik>0)cout<<"TAK\n"; else cout<<"NIE\n"; } return 0; } |