#include <cstdio> #include <iostream> #include <vector> #include <queue> #include <stack> #include <string.h> #include <stdlib.h> #include <list> #include <set> #include <math.h> #include <algorithm> #define FOR(x,y,z) for(int x = (y); x < (z); x++) #define FORD(x,y,z) for(int x = (y); x >= z; x--) #define REP(r,n) for(int r = 0; r < ((int) n); r++) #define MP make_pair #define ST first #define ND second #define PB push_back #define PF push_front #define MAXUS 100003 #define MODUL 1000 #define MAXUS2 9000005 using namespace std; typedef long long LL; typedef long double LD; typedef vector<int> VI; typedef pair<LL, LL> PR; typedef unsigned long long ULL; LL T[4][MAXUS]; int main() { int z,n; LL m_w1,m_w2,m_h1,m_h2; scanf("%d",&z); while(z--) { scanf("%d",&n); REP(i,n) scanf("%lld %lld %lld %lld",&T[0][i],&T[1][i],&T[2][i],&T[3][i]); bool result = false; m_w1 = T[0][0]; m_w2 = T[1][0]; m_h1 = T[2][0]; m_h2 = T[3][0]; FOR(i,1,n) { if( m_w1 > T[0][i] ) m_w1 = T[0][i]; if( m_w2 < T[1][i] ) m_w2 = T[1][i]; if( m_h1 > T[2][i] ) m_h1 = T[2][i]; if( m_h2 < T[3][i] ) m_h2 = T[3][i]; } REP(i,n) { if( m_w1 == T[0][i] && m_w2 == T[1][i] && T[2][i] == m_h1 && T[3][i] == m_h2) { result = true; break; } } if(result) printf("TAK\n"); else printf("NIE\n"); } 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 | #include <cstdio> #include <iostream> #include <vector> #include <queue> #include <stack> #include <string.h> #include <stdlib.h> #include <list> #include <set> #include <math.h> #include <algorithm> #define FOR(x,y,z) for(int x = (y); x < (z); x++) #define FORD(x,y,z) for(int x = (y); x >= z; x--) #define REP(r,n) for(int r = 0; r < ((int) n); r++) #define MP make_pair #define ST first #define ND second #define PB push_back #define PF push_front #define MAXUS 100003 #define MODUL 1000 #define MAXUS2 9000005 using namespace std; typedef long long LL; typedef long double LD; typedef vector<int> VI; typedef pair<LL, LL> PR; typedef unsigned long long ULL; LL T[4][MAXUS]; int main() { int z,n; LL m_w1,m_w2,m_h1,m_h2; scanf("%d",&z); while(z--) { scanf("%d",&n); REP(i,n) scanf("%lld %lld %lld %lld",&T[0][i],&T[1][i],&T[2][i],&T[3][i]); bool result = false; m_w1 = T[0][0]; m_w2 = T[1][0]; m_h1 = T[2][0]; m_h2 = T[3][0]; FOR(i,1,n) { if( m_w1 > T[0][i] ) m_w1 = T[0][i]; if( m_w2 < T[1][i] ) m_w2 = T[1][i]; if( m_h1 > T[2][i] ) m_h1 = T[2][i]; if( m_h2 < T[3][i] ) m_h2 = T[3][i]; } REP(i,n) { if( m_w1 == T[0][i] && m_w2 == T[1][i] && T[2][i] == m_h1 && T[3][i] == m_h2) { result = true; break; } } if(result) printf("TAK\n"); else printf("NIE\n"); } return 0; } |