#include <algorithm>
#include <iostream>
#include <cstdio>
#include <assert.h>
using namespace std;
typedef long long LL;
#define FOR(x,b,e) for(int x=b; x<=(e); ++x)
#define REP(x,n) for(int x=0; x<(n); ++x)
#define FORD(x,b,e) for(int x=b; x>=(e); --x)
#define w1 0
#define w2 1
#define h1 2
#define h2 3
int tab[100001][4];
void testCase(int n){
int dx = -1;
int dy = -1;
int nr = -1;
REP(x,n){
if(abs(tab[x][w1]-tab[x][w2]) > dx || abs(tab[x][h1]-tab[x][h2]) > dy){
nr = x;
dx = abs(tab[x][w1]-tab[x][w2]);
dy = abs(tab[x][h1]-tab[x][h2]);
}
}
REP(x,n)
if( tab[x][w1]<tab[nr][w1]
|| tab[x][w2]>tab[nr][w2]
|| tab[x][h1]<tab[nr][h1]
|| tab[x][h2]>tab[nr][h2]
)
{ printf("NIE\n"); return;}
printf("TAK\n");
}
int main() {
int t = 0;
int n = 0;
scanf("%d",&t);
REP(x,t){
scanf("%d",&n);
REP(y,n)scanf("%d %d %d %d",&tab[y][w1],&tab[y][w2],&tab[y][h1],&tab[y][h2]);
testCase(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 | #include <algorithm> #include <iostream> #include <cstdio> #include <assert.h> using namespace std; typedef long long LL; #define FOR(x,b,e) for(int x=b; x<=(e); ++x) #define REP(x,n) for(int x=0; x<(n); ++x) #define FORD(x,b,e) for(int x=b; x>=(e); --x) #define w1 0 #define w2 1 #define h1 2 #define h2 3 int tab[100001][4]; void testCase(int n){ int dx = -1; int dy = -1; int nr = -1; REP(x,n){ if(abs(tab[x][w1]-tab[x][w2]) > dx || abs(tab[x][h1]-tab[x][h2]) > dy){ nr = x; dx = abs(tab[x][w1]-tab[x][w2]); dy = abs(tab[x][h1]-tab[x][h2]); } } REP(x,n) if( tab[x][w1]<tab[nr][w1] || tab[x][w2]>tab[nr][w2] || tab[x][h1]<tab[nr][h1] || tab[x][h2]>tab[nr][h2] ) { printf("NIE\n"); return;} printf("TAK\n"); } int main() { int t = 0; int n = 0; scanf("%d",&t); REP(x,t){ scanf("%d",&n); REP(y,n)scanf("%d %d %d %d",&tab[y][w1],&tab[y][w2],&tab[y][h1],&tab[y][h2]); testCase(n); } return 0; } |
English