// Konrad Szlesinski #include <iostream> #include <string> #include <sstream> #include <cstdio> #include <cstdlib> #include <ctime> #include <algorithm> #include <cmath> #include <cctype> #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <bitset> #include <limits> using namespace std; typedef vector<bool> VB; typedef vector<int> VI; typedef long long LL; typedef vector<LL> VLL; typedef unsigned long long ULL; typedef vector<ULL> VULL; typedef vector<VI> VVI; typedef pair<int,int> PII; typedef vector<PII> VPII; typedef set<int> SI; typedef vector<SI> VSI; typedef set<VI> SVI; typedef multiset<int> mSI; typedef map<int,int> MII; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define FORD(i,a,b) for(int i=(b)-1;i>=(a);--i) #define REP(i,n) FOR(i,0,n) #define REPD(i,n) FORD(i,0,n) #define VAR(v,w) __typeof(w) v=(w) #define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it) #define FORED(it,c) for(VAR(it,(c).rbegin());it!=(c).rend();++it) #define FORENA(it,c) for(VAR(it,(c).begin());it!=(c).end();) #define ALL(c) (c).begin(),(c).end() #define PF push_front #define POF pop_front #define PB push_back #define POB pop_back #define PH push_heap #define POH pop_heap #define INS insert #define ER erase #define MH make_heap #define MP make_pair #define FT first #define SD second int main() { ios_base::sync_with_stdio(false); const int INF = 2000000000; int z, n; scanf("%d", &z); while(z--) { scanf("%d", &n); int D[n][4], B[] = {INF, -INF, INF, -INF}; REP(i, n) { REP(j, 4) scanf("%d", &D[i][j]); B[0] = min(B[0], D[i][0]); B[1] = max(B[1], D[i][1]); B[2] = min(B[2], D[i][2]); B[3] = max(B[3], D[i][3]); } bool found; REP(i, n) { found = true; REP(j, 4) if(D[i][j] != B[j]) { found = false; break; } if(found) break; } printf("%s\n", found? "TAK" : "NIE"); } 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | // Konrad Szlesinski #include <iostream> #include <string> #include <sstream> #include <cstdio> #include <cstdlib> #include <ctime> #include <algorithm> #include <cmath> #include <cctype> #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <bitset> #include <limits> using namespace std; typedef vector<bool> VB; typedef vector<int> VI; typedef long long LL; typedef vector<LL> VLL; typedef unsigned long long ULL; typedef vector<ULL> VULL; typedef vector<VI> VVI; typedef pair<int,int> PII; typedef vector<PII> VPII; typedef set<int> SI; typedef vector<SI> VSI; typedef set<VI> SVI; typedef multiset<int> mSI; typedef map<int,int> MII; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define FORD(i,a,b) for(int i=(b)-1;i>=(a);--i) #define REP(i,n) FOR(i,0,n) #define REPD(i,n) FORD(i,0,n) #define VAR(v,w) __typeof(w) v=(w) #define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it) #define FORED(it,c) for(VAR(it,(c).rbegin());it!=(c).rend();++it) #define FORENA(it,c) for(VAR(it,(c).begin());it!=(c).end();) #define ALL(c) (c).begin(),(c).end() #define PF push_front #define POF pop_front #define PB push_back #define POB pop_back #define PH push_heap #define POH pop_heap #define INS insert #define ER erase #define MH make_heap #define MP make_pair #define FT first #define SD second int main() { ios_base::sync_with_stdio(false); const int INF = 2000000000; int z, n; scanf("%d", &z); while(z--) { scanf("%d", &n); int D[n][4], B[] = {INF, -INF, INF, -INF}; REP(i, n) { REP(j, 4) scanf("%d", &D[i][j]); B[0] = min(B[0], D[i][0]); B[1] = max(B[1], D[i][1]); B[2] = min(B[2], D[i][2]); B[3] = max(B[3], D[i][3]); } bool found; REP(i, n) { found = true; REP(j, 4) if(D[i][j] != B[j]) { found = false; break; } if(found) break; } printf("%s\n", found? "TAK" : "NIE"); } return 0; } |