#include<iostream>
#include<cstdio>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<deque>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<sstream>
#include<cstring>
using namespace std;
#define FOR(I,A,B) for(int I=(A);I<=(B);I++)
#define REP(I,N) for(int I=0;I<(N);I++)
#define ALL(X) (X).begin(),(X).end()
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;
typedef vector<string> VS;
#define FORD(I,A,B) for(int I=(A);I>=(B);I--)
#define INFTY 100000000
#define VAR(V,init) __typeof(init) V=(init)
#define FOREACH(I,C) for(VAR(I,(C).begin());I!=(C).end();I++)
#define PRINT1(a) cout << a << endl;
#define PRINT2(a, b) cout << a << ": " << b << endl;
#define PRINT3(a, b, c) cout << a << ": " << b << ", " << c << endl;
#define PRINT4(a, b, c, d) cout << a << ": " << b << ", " << c << ", "<< d << endl;
int main(){
ios_base::sync_with_stdio(0);
int t, n, w1, w2, h1, h2;
cin >> t;
//testcases:
REP(tt, t)
{
int n, w1, w2, h1, h2;
cin >> n;
//cout << "n:" << n << endl;
VI min_w;
VI max_w;
VI min_h;
VI max_h;
int minw = 1000000001;
int maxw = 0;
int minh = 1000000001;
int maxh = 0;
REP(i, n)
{
cin >> w1 >> w2 >> h1 >> h2;
//PRINT1("read w1, w2, h1, h2")
//PRINT4(w1, w2, h1, h2)
min_w.push_back(w1);
max_w.push_back(w2);
min_h.push_back(h1);
max_h.push_back(h2);
minw = min(minw, w1);
maxw = max(maxw, w2);
minh = min(minh, h1);
maxh = max(maxh, h2);
}
//PRINT1("read minw, maxw, minh, maxh")
//PRINT4(minw, maxw, minh, maxh)
bool found = false;
REP(i, n)
{
if (min_w[i] == minw && max_w[i] == maxw && min_h[i] == minh && max_h[i] == maxh)
found = true;
}
if (found)
cout << "TAK" << endl;
else
cout << "NIE" << endl;
}
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 | #include<iostream> #include<cstdio> #include<cctype> #include<cmath> #include<cstdlib> #include<algorithm> #include<vector> #include<string> #include<list> #include<deque> #include<map> #include<set> #include<queue> #include<stack> #include<utility> #include<sstream> #include<cstring> using namespace std; #define FOR(I,A,B) for(int I=(A);I<=(B);I++) #define REP(I,N) for(int I=0;I<(N);I++) #define ALL(X) (X).begin(),(X).end() #define PB push_back #define MP make_pair #define FI first #define SE second typedef vector<int> VI; typedef pair<int,int> PII; typedef long long ll; typedef vector<string> VS; #define FORD(I,A,B) for(int I=(A);I>=(B);I--) #define INFTY 100000000 #define VAR(V,init) __typeof(init) V=(init) #define FOREACH(I,C) for(VAR(I,(C).begin());I!=(C).end();I++) #define PRINT1(a) cout << a << endl; #define PRINT2(a, b) cout << a << ": " << b << endl; #define PRINT3(a, b, c) cout << a << ": " << b << ", " << c << endl; #define PRINT4(a, b, c, d) cout << a << ": " << b << ", " << c << ", "<< d << endl; int main(){ ios_base::sync_with_stdio(0); int t, n, w1, w2, h1, h2; cin >> t; //testcases: REP(tt, t) { int n, w1, w2, h1, h2; cin >> n; //cout << "n:" << n << endl; VI min_w; VI max_w; VI min_h; VI max_h; int minw = 1000000001; int maxw = 0; int minh = 1000000001; int maxh = 0; REP(i, n) { cin >> w1 >> w2 >> h1 >> h2; //PRINT1("read w1, w2, h1, h2") //PRINT4(w1, w2, h1, h2) min_w.push_back(w1); max_w.push_back(w2); min_h.push_back(h1); max_h.push_back(h2); minw = min(minw, w1); maxw = max(maxw, w2); minh = min(minh, h1); maxh = max(maxh, h2); } //PRINT1("read minw, maxw, minh, maxh") //PRINT4(minw, maxw, minh, maxh) bool found = false; REP(i, n) { if (min_w[i] == minw && max_w[i] == maxw && min_h[i] == minh && max_h[i] == maxh) found = true; } if (found) cout << "TAK" << endl; else cout << "NIE" << endl; } return 0; } |
English