#include <cstdio> using namespace std; const int INF = 2000000009; bool found; int t, n, wmin, wmax, hmin, hmax; int w1[100005], w2[100005], h1[100005], h2[100005]; int main() { scanf("%d", &t); for(int i=0; i<t; i++) { wmin=INF; wmax=0; hmin=INF; hmax=0; scanf("%d", &n); for(int j=0; j<n; j++) { scanf("%d%d%d%d", &w1[j], &w2[j], &h1[j], &h2[j]); if(w1[j]<wmin) wmin=w1[j]; if(w2[j]>wmax) wmax=w2[j]; if(h1[j]<hmin) hmin=h1[j]; if(h2[j]>hmax) hmax=h2[j]; } for(int j=0; j<n; j++) { if(w1[j]==wmin && w2[j]==wmax && h1[j]==hmin && h2[j]==hmax) { printf("TAK\n"); found=true; break; } } if(!found) { printf("NIE\n"); } else { found=false; } } 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 | #include <cstdio> using namespace std; const int INF = 2000000009; bool found; int t, n, wmin, wmax, hmin, hmax; int w1[100005], w2[100005], h1[100005], h2[100005]; int main() { scanf("%d", &t); for(int i=0; i<t; i++) { wmin=INF; wmax=0; hmin=INF; hmax=0; scanf("%d", &n); for(int j=0; j<n; j++) { scanf("%d%d%d%d", &w1[j], &w2[j], &h1[j], &h2[j]); if(w1[j]<wmin) wmin=w1[j]; if(w2[j]>wmax) wmax=w2[j]; if(h1[j]<hmin) hmin=h1[j]; if(h2[j]>hmax) hmax=h2[j]; } for(int j=0; j<n; j++) { if(w1[j]==wmin && w2[j]==wmax && h1[j]==hmin && h2[j]==hmax) { printf("TAK\n"); found=true; break; } } if(!found) { printf("NIE\n"); } else { found=false; } } return 0; } |