#include <cstdio>
#include <utility>
#include <functional>
using namespace std;
//this is ugly
int best = -1;
template<typename T>
inline int foo(int& p, int i, T comp)
{
if (comp(i, p))
{
p = i;
best = -1;
return 1;
}
else return p == i;
}
int main(int argc, char** argv)
{
int t;
scanf("%d", &t);
while (t--)
{
int n;
int w1 = 0x70000000,
w2 = 0;
int h1 = w1, h2 = w2;
best = -1;
scanf("%d", &n);
while (n--)
{
int tw1, tw2, th1, th2, k = 0;
scanf("%d %d %d %d", &tw1, &tw2, &th1, &th2);
k += foo(w1, tw1, less<int>());
k += foo(w2, tw2, greater<int>());
k += foo(h1, th1, less<int>());
k += foo(h2, th2, greater<int>());
if (k == 4)
best = n;
}
//printf("%d %d %d %d\n", w1, w2, h1, h2);
printf("%s\n", (best != -1)?"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 | #include <cstdio> #include <utility> #include <functional> using namespace std; //this is ugly int best = -1; template<typename T> inline int foo(int& p, int i, T comp) { if (comp(i, p)) { p = i; best = -1; return 1; } else return p == i; } int main(int argc, char** argv) { int t; scanf("%d", &t); while (t--) { int n; int w1 = 0x70000000, w2 = 0; int h1 = w1, h2 = w2; best = -1; scanf("%d", &n); while (n--) { int tw1, tw2, th1, th2, k = 0; scanf("%d %d %d %d", &tw1, &tw2, &th1, &th2); k += foo(w1, tw1, less<int>()); k += foo(w2, tw2, greater<int>()); k += foo(h1, th1, less<int>()); k += foo(h2, th2, greater<int>()); if (k == 4) best = n; } //printf("%d %d %d %d\n", w1, w2, h1, h2); printf("%s\n", (best != -1)?"TAK":"NIE"); } } |
English