#include <cstdio> #include <vector> #include <queue> #include <stack> #include <cstring> #include <iostream> #include <algorithm> #include <set> #define MAXN 100007 #define INF #define PB push_back #define MP make_pair #define ST first #define ND second #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(a,b,c) for(int a=b;a<=(c);a++) #define FORD(a,b,c) for (int a=b;a>=(c);a--) #define VAR(v,n) __typeof(n) v=(n) #define ALL(c) c.begin(),c.end() #define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++) using namespace std; typedef long long LL; typedef pair<int,int> PII; int n,testy; int stan[MAXN]; PII w[MAXN], h[MAXN]; bool check_in(PII a, PII b) { return a.ST >= b.ST && a.ND <= b.ND; } void sprawdz(PII *t) { int dl = 0, kt; bool mozna = true; REP(i,n) dl = max(dl,t[i].ND-t[i].ST); REP(i,n) if (t[i].ND-t[i].ST == dl) kt = i; REP(i,n) mozna &= check_in(t[i],t[kt]); if (mozna) REP(i,n) if (t[i].ND - t[i].ST == dl) ++stan[i]; } bool check() { REP(i,n) if (stan[i] == 2) return true; return false; } int main(){ scanf("%d",&testy); while (testy--) { scanf("%d",&n); REP(i,n) stan[i] = 0; REP(i,n) scanf("%d%d%d%d",&w[i].ST,&w[i].ND,&h[i].ST,&h[i].ND); sprawdz(w); sprawdz(h); puts(check() ? "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 | #include <cstdio> #include <vector> #include <queue> #include <stack> #include <cstring> #include <iostream> #include <algorithm> #include <set> #define MAXN 100007 #define INF #define PB push_back #define MP make_pair #define ST first #define ND second #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(a,b,c) for(int a=b;a<=(c);a++) #define FORD(a,b,c) for (int a=b;a>=(c);a--) #define VAR(v,n) __typeof(n) v=(n) #define ALL(c) c.begin(),c.end() #define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++) using namespace std; typedef long long LL; typedef pair<int,int> PII; int n,testy; int stan[MAXN]; PII w[MAXN], h[MAXN]; bool check_in(PII a, PII b) { return a.ST >= b.ST && a.ND <= b.ND; } void sprawdz(PII *t) { int dl = 0, kt; bool mozna = true; REP(i,n) dl = max(dl,t[i].ND-t[i].ST); REP(i,n) if (t[i].ND-t[i].ST == dl) kt = i; REP(i,n) mozna &= check_in(t[i],t[kt]); if (mozna) REP(i,n) if (t[i].ND - t[i].ST == dl) ++stan[i]; } bool check() { REP(i,n) if (stan[i] == 2) return true; return false; } int main(){ scanf("%d",&testy); while (testy--) { scanf("%d",&n); REP(i,n) stan[i] = 0; REP(i,n) scanf("%d%d%d%d",&w[i].ST,&w[i].ND,&h[i].ST,&h[i].ND); sprawdz(w); sprawdz(h); puts(check() ? "TAK" : "NIE"); } return 0; } |