#include<cstdio>
#include<vector>
#include<algorithm>
#define INF 1000000007
using namespace std;
void solve()
{
int n;
int t[4], w[4] = {INF, -1, INF, -1}, nr = -1;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
for(int j = 0 ; j < 4; j++)
{
scanf("%d", &t[j]);
if((j&1) && t[j] > w[j])
{
w[j] = t[j];
nr = -1;
}
else if(!(j&1) && t[j] < w[j])
{
w[j] = t[j];
nr = -1;
}
}
if(t[1] >= w[1] && t[3] >= w[3] && t[0] <= w[0] && t[2] <= w[2])
{
nr = i;
}
}
if(nr != -1)
{
printf("TAK\n");
}
else printf("NIE\n");
}
int main()
{
int n;
scanf("%d", &n);
while(n--)solve();
}
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 | #include<cstdio> #include<vector> #include<algorithm> #define INF 1000000007 using namespace std; void solve() { int n; int t[4], w[4] = {INF, -1, INF, -1}, nr = -1; scanf("%d", &n); for(int i = 0; i < n; i++) { for(int j = 0 ; j < 4; j++) { scanf("%d", &t[j]); if((j&1) && t[j] > w[j]) { w[j] = t[j]; nr = -1; } else if(!(j&1) && t[j] < w[j]) { w[j] = t[j]; nr = -1; } } if(t[1] >= w[1] && t[3] >= w[3] && t[0] <= w[0] && t[2] <= w[2]) { nr = i; } } if(nr != -1) { printf("TAK\n"); } else printf("NIE\n"); } int main() { int n; scanf("%d", &n); while(n--)solve(); } |
English