#include <cstdio> #include <algorithm> using namespace std; const int MAXN = 100005, INF = 1000000009; int t, n; int minw, maxw, minh, maxh; int w1, w2, h1, h2; int main() { scanf("%d", &t); for(int i=0; i<t; i++) { int tmpw1, tmpw2, tmph1, tmph2; minw = minh = INF; maxw = maxh = 0; w1 = w2 = h1 = h2 = 0; scanf("%d", &n); for(int j=0; j<n; j++) { scanf("%d%d%d%d", &tmpw1, &tmpw2, &tmph1, &tmph2); minw = min(minw, tmpw1); maxw = max(maxw, tmpw2); minh = min(minh, tmph1); maxh = max(maxh, tmph2); if(tmpw1 <= minw && tmpw2 >= maxw && tmph1 <= minh && tmph2 >= maxh) { w1 = tmpw1; w2 = tmpw2; h1 = tmph1; h2 = tmph2; } } if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) printf("TAK\n"); else printf("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 | #include <cstdio> #include <algorithm> using namespace std; const int MAXN = 100005, INF = 1000000009; int t, n; int minw, maxw, minh, maxh; int w1, w2, h1, h2; int main() { scanf("%d", &t); for(int i=0; i<t; i++) { int tmpw1, tmpw2, tmph1, tmph2; minw = minh = INF; maxw = maxh = 0; w1 = w2 = h1 = h2 = 0; scanf("%d", &n); for(int j=0; j<n; j++) { scanf("%d%d%d%d", &tmpw1, &tmpw2, &tmph1, &tmph2); minw = min(minw, tmpw1); maxw = max(maxw, tmpw2); minh = min(minh, tmph1); maxh = max(maxh, tmph2); if(tmpw1 <= minw && tmpw2 >= maxw && tmph1 <= minh && tmph2 >= maxh) { w1 = tmpw1; w2 = tmpw2; h1 = tmph1; h2 = tmph2; } } if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) printf("TAK\n"); else printf("NIE\n"); } return 0; } |