#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define INF 1000000001
struct Mirror{
int minWidth;
int maxWidth;
int minHeight;
int maxHeight;
Mirror(int minW, int maxW, int minH, int maxH)
: minWidth(minW), maxWidth(maxW), minHeight(minH), maxHeight(maxH){}
bool majorises(Mirror& that){
return
this->minWidth == that.minWidth &&
this->minHeight == that.minHeight &&
this->maxWidth == that.maxWidth &&
this->maxHeight == that.maxHeight;
}
Mirror(){}
};
void readInputAndPrintResult(){
int n;
scanf("%d", &n);
Mirror mirrors[n];
Mirror extreme = Mirror(INF, -INF, INF, -INF);
for(int i=0; i<n; i++){
int minw, maxw, minh, maxh;
scanf("%d%d%d%d", &minw, &maxw, &minh, &maxh);
mirrors[i] = Mirror(minw, maxw, minh, maxh);
extreme.minHeight = min(extreme.minHeight, mirrors[i].minHeight);
extreme.minWidth = min(extreme.minWidth, mirrors[i].minWidth);
extreme.maxHeight = max(extreme.maxHeight, mirrors[i].maxHeight);
extreme.maxWidth = max(extreme.maxWidth, mirrors[i].maxWidth);
}
for(int i=0; i<n; i++){
if(mirrors[i].majorises(extreme)){
printf("TAK\n");
return;
}
}
printf("NIE\n");
}
int main(){
int testCount;
scanf("%d", &testCount);
for(int i=0; i<testCount; i++)
readInputAndPrintResult();
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 | #include <cstdio> #include <cmath> #include <algorithm> using namespace std; #define INF 1000000001 struct Mirror{ int minWidth; int maxWidth; int minHeight; int maxHeight; Mirror(int minW, int maxW, int minH, int maxH) : minWidth(minW), maxWidth(maxW), minHeight(minH), maxHeight(maxH){} bool majorises(Mirror& that){ return this->minWidth == that.minWidth && this->minHeight == that.minHeight && this->maxWidth == that.maxWidth && this->maxHeight == that.maxHeight; } Mirror(){} }; void readInputAndPrintResult(){ int n; scanf("%d", &n); Mirror mirrors[n]; Mirror extreme = Mirror(INF, -INF, INF, -INF); for(int i=0; i<n; i++){ int minw, maxw, minh, maxh; scanf("%d%d%d%d", &minw, &maxw, &minh, &maxh); mirrors[i] = Mirror(minw, maxw, minh, maxh); extreme.minHeight = min(extreme.minHeight, mirrors[i].minHeight); extreme.minWidth = min(extreme.minWidth, mirrors[i].minWidth); extreme.maxHeight = max(extreme.maxHeight, mirrors[i].maxHeight); extreme.maxWidth = max(extreme.maxWidth, mirrors[i].maxWidth); } for(int i=0; i<n; i++){ if(mirrors[i].majorises(extreme)){ printf("TAK\n"); return; } } printf("NIE\n"); } int main(){ int testCount; scanf("%d", &testCount); for(int i=0; i<testCount; i++) readInputAndPrintResult(); return 0; } |
polski