#include <stdio.h> #include <algorithm> using namespace std; struct mirror_t { int widthMin, widthMax; int heightMin, heightMax; }; const int INF = 1000 * 1000 * 1000 + 1; int main() { int t; scanf("%d", &t); for(int i = 0; i < t; ++i) { int n; scanf("%d", &n); mirror_t mirrors[n]; mirror_t major = { widthMin: INF, widthMax: -INF, heightMin: INF, heightMax: -INF, }; for(int j = 0; j < n; ++j) { scanf("%d %d %d %d", &mirrors[j].widthMin, &mirrors[j].widthMax, &mirrors[j].heightMin, &mirrors[j].heightMax); major.widthMin = min(major.widthMin, mirrors[j].widthMin); major.widthMax = max(major.widthMax, mirrors[j].widthMax); major.heightMin = min(major.heightMin, mirrors[j].heightMin); major.heightMax = max(major.heightMax, mirrors[j].heightMax); } bool found = false; for(int j = 0; j < n; j++) { if(mirrors[j].widthMin == major.widthMin && mirrors[j].widthMax == major.widthMax && mirrors[j].heightMin == major.heightMin && mirrors[j].heightMax == major.heightMax) { printf("TAK\n"); found = true; break; } } if(!found) 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 41 42 43 44 45 46 | #include <stdio.h> #include <algorithm> using namespace std; struct mirror_t { int widthMin, widthMax; int heightMin, heightMax; }; const int INF = 1000 * 1000 * 1000 + 1; int main() { int t; scanf("%d", &t); for(int i = 0; i < t; ++i) { int n; scanf("%d", &n); mirror_t mirrors[n]; mirror_t major = { widthMin: INF, widthMax: -INF, heightMin: INF, heightMax: -INF, }; for(int j = 0; j < n; ++j) { scanf("%d %d %d %d", &mirrors[j].widthMin, &mirrors[j].widthMax, &mirrors[j].heightMin, &mirrors[j].heightMax); major.widthMin = min(major.widthMin, mirrors[j].widthMin); major.widthMax = max(major.widthMax, mirrors[j].widthMax); major.heightMin = min(major.heightMin, mirrors[j].heightMin); major.heightMax = max(major.heightMax, mirrors[j].heightMax); } bool found = false; for(int j = 0; j < n; j++) { if(mirrors[j].widthMin == major.widthMin && mirrors[j].widthMax == major.widthMax && mirrors[j].heightMin == major.heightMin && mirrors[j].heightMax == major.heightMax) { printf("TAK\n"); found = true; break; } } if(!found) printf("NIE\n"); } return 0; } |