#include<cstdio> #define inf 2000000000 using namespace std; int T[100010][4]; int main(){ int t; scanf("%d", &t); while(t--){ int n; scanf("%d", &n); bool res = true; int b1 = inf, b2 = -inf, b3 = inf, b4 = -inf; for(int i = 0; i < n; ++i){ scanf("%d %d %d %d", &T[i][0], &T[i][1], &T[i][2], &T[i][3]); if(T[i][0] <= b1 && T[i][1] >= b2 && T[i][2] <= b3 && T[i][3] >= b4){ b1 = T[i][0]; b2 = T[i][1]; b3 = T[i][2]; b4 = T[i][3]; } } for(int i = 0; i < n; ++i){ if(T[i][0] < b1 || T[i][1] > b2 || T[i][2] < b3 || T[i][3] > b4) res = false; } printf(res?"TAK\n":"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 | #include<cstdio> #define inf 2000000000 using namespace std; int T[100010][4]; int main(){ int t; scanf("%d", &t); while(t--){ int n; scanf("%d", &n); bool res = true; int b1 = inf, b2 = -inf, b3 = inf, b4 = -inf; for(int i = 0; i < n; ++i){ scanf("%d %d %d %d", &T[i][0], &T[i][1], &T[i][2], &T[i][3]); if(T[i][0] <= b1 && T[i][1] >= b2 && T[i][2] <= b3 && T[i][3] >= b4){ b1 = T[i][0]; b2 = T[i][1]; b3 = T[i][2]; b4 = T[i][3]; } } for(int i = 0; i < n; ++i){ if(T[i][0] < b1 || T[i][1] > b2 || T[i][2] < b3 || T[i][3] > b4) res = false; } printf(res?"TAK\n":"NIE\n"); } return 0; } |