#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<sstream> #include<cmath> #include<cstdio> using namespace std; #define REP(i,n) for(int i=0;i<n;++i) #define REPD(i,n) for(int i=n;i>-1;--i) #define FOR(i,j,k) for(int i=j;i<k;++i) #define PB push_back #define LL long long #define MAX_S 101 #define MP make_pair #define ALL(v) v.begin(),v.end() #define INF 1000000001 int main(){ int ts=0; vector<vector<LL> > d(100000); REP(i,100000) d[i].resize(4); scanf("%d\n",&ts); REP(ww,ts) { LL minW=INF,maxW=0,minH=INF,maxH=0; int n; scanf("%d\n",&n); REP(i,n) { REP(j,4) { int x; scanf("%d",&x); d[i][j] = x; } minW = min(minW,d[i][0]); maxW = max(maxW,d[i][1]); minH = min(minH,d[i][2]); maxH = max(maxH,d[i][3]); } string ret = "NIE"; REP(i,n) { if(d[i][0]<=minW && d[i][1]>=maxW && d[i][2]<=minH && d[i][3]>=maxH) { ret="TAK"; break; } } printf("%s\n",ret.c_str()); } 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 | #include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<sstream> #include<cmath> #include<cstdio> using namespace std; #define REP(i,n) for(int i=0;i<n;++i) #define REPD(i,n) for(int i=n;i>-1;--i) #define FOR(i,j,k) for(int i=j;i<k;++i) #define PB push_back #define LL long long #define MAX_S 101 #define MP make_pair #define ALL(v) v.begin(),v.end() #define INF 1000000001 int main(){ int ts=0; vector<vector<LL> > d(100000); REP(i,100000) d[i].resize(4); scanf("%d\n",&ts); REP(ww,ts) { LL minW=INF,maxW=0,minH=INF,maxH=0; int n; scanf("%d\n",&n); REP(i,n) { REP(j,4) { int x; scanf("%d",&x); d[i][j] = x; } minW = min(minW,d[i][0]); maxW = max(maxW,d[i][1]); minH = min(minH,d[i][2]); maxH = max(maxH,d[i][3]); } string ret = "NIE"; REP(i,n) { if(d[i][0]<=minW && d[i][1]>=maxW && d[i][2]<=minH && d[i][3]>=maxH) { ret="TAK"; break; } } printf("%s\n",ret.c_str()); } return 0; } |