#define DBG
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdarg>
using namespace std;
#define PB push_back
#define IT iterator
#define MP make_pair
#define F first
#define S second
#define X first
#define Y second
#define NL printf("\n")
#define SZ(v) ((int)(v).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define FORC(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define W(x) do { if (DBG) printf("%s:%d %s = %d\n", __LINE__, __func__, #x, x); } while (0)
typedef long double LD;
typedef double DL;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LD,LD> PLD;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<PII> VPII;
void memcheck()
{
#ifdef DBG
char c[100];
FILE *p = fopen("/proc/self/status","r");
while (fgets(c,100,p) )
if (strncmp("VmPeak",c,6)==0)
fputs(c, stderr);
fclose(p);
#endif
}
//------ /headers --------
void _printf(const char *s, ...)
{
#ifdef DBG
va_list vl;
va_start(vl, s);
vfprintf(stderr, s, vl);
#endif
}
int tests;
int n;
const int MAXN = 100010;
int w1[MAXN], w2[MAXN], h1[MAXN], h2[MAXN];
int minw, maxw, minh, maxh;
int main() {
scanf("%d", &tests);
while (tests--) {
scanf("%d", &n);
REP(i, n) {
scanf("%d%d%d%d", w1 + i, w2 + i, h1 + i, h2 + i);
if (i) {
minw = min(minw, w1[i]);
maxw = max(maxw, w2[i]);
minh = min(minh, h1[i]);
maxh = max(maxh, h2[i]);
} else {
minw = w1[i];
maxw = w2[i];
minh = h1[i];
maxh = h2[i];
}
}
bool found = false;
REP(i, n) {
if (minw == w1[i] && maxw == w2[i] && minh == h1[i] && maxh == h2[i]) {
found = true;
break;
}
}
printf("%s\n", found ? "TAK" : "NIE");
}
}
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 94 95 96 97 98 99 100 | #define DBG #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <deque> #include <list> #include <set> #include <map> #include <cstdlib> #include <cassert> #include <cmath> #include <cstdarg> using namespace std; #define PB push_back #define IT iterator #define MP make_pair #define F first #define S second #define X first #define Y second #define NL printf("\n") #define SZ(v) ((int)(v).size()) #define ALL(x) (x).begin(), (x).end() #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define FORE(i,a,b) for(int i=(a);i<=(b);++i) #define FORD(i,a,b) for(int i=(a);i>=(b);--i) #define FORC(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i) #define W(x) do { if (DBG) printf("%s:%d %s = %d\n", __LINE__, __func__, #x, x); } while (0) typedef long double LD; typedef double DL; typedef long long LL; typedef unsigned long long ULL; typedef pair<LD,LD> PLD; typedef pair<int,int> PII; typedef pair<LL,LL> PLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<PII> VPII; void memcheck() { #ifdef DBG char c[100]; FILE *p = fopen("/proc/self/status","r"); while (fgets(c,100,p) ) if (strncmp("VmPeak",c,6)==0) fputs(c, stderr); fclose(p); #endif } //------ /headers -------- void _printf(const char *s, ...) { #ifdef DBG va_list vl; va_start(vl, s); vfprintf(stderr, s, vl); #endif } int tests; int n; const int MAXN = 100010; int w1[MAXN], w2[MAXN], h1[MAXN], h2[MAXN]; int minw, maxw, minh, maxh; int main() { scanf("%d", &tests); while (tests--) { scanf("%d", &n); REP(i, n) { scanf("%d%d%d%d", w1 + i, w2 + i, h1 + i, h2 + i); if (i) { minw = min(minw, w1[i]); maxw = max(maxw, w2[i]); minh = min(minh, h1[i]); maxh = max(maxh, h2[i]); } else { minw = w1[i]; maxw = w2[i]; minh = h1[i]; maxh = h2[i]; } } bool found = false; REP(i, n) { if (minw == w1[i] && maxw == w2[i] && minh == h1[i] && maxh == h2[i]) { found = true; break; } } printf("%s\n", found ? "TAK" : "NIE"); } } |
English