#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
bool solve() {
int N, i, w1, w2, h1, h2, bestw1, bestw2, besth1, besth2;
scanf("%d", &N);
N--;
bool ok=true;
scanf("%d%d%d%d", &bestw1, &bestw2, &besth1, &besth2);
while (N--) {
scanf("%d%d%d%d", &w1, &w2, &h1, &h2);
if (w1<=bestw1 && w2>=bestw2 && h1<=besth1 && h2>=besth2)
ok=true;
else if (w1<bestw1 || w2>bestw2 || h1<besth1 || h2>besth2)
ok=false;
bestw1=min(bestw1,w1);
bestw2=max(bestw2,w2);
besth1=min(besth1,h1);
besth2=max(besth2,h2);
}
return ok;
}
int main() {
int T;
scanf("%d", &T);
while (T--)
if (solve())
puts("TAK");
else
puts("NIE");
#ifdef __WIN32
system("pause");
#endif
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 | #include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; bool solve() { int N, i, w1, w2, h1, h2, bestw1, bestw2, besth1, besth2; scanf("%d", &N); N--; bool ok=true; scanf("%d%d%d%d", &bestw1, &bestw2, &besth1, &besth2); while (N--) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); if (w1<=bestw1 && w2>=bestw2 && h1<=besth1 && h2>=besth2) ok=true; else if (w1<bestw1 || w2>bestw2 || h1<besth1 || h2>besth2) ok=false; bestw1=min(bestw1,w1); bestw2=max(bestw2,w2); besth1=min(besth1,h1); besth2=max(besth2,h2); } return ok; } int main() { int T; scanf("%d", &T); while (T--) if (solve()) puts("TAK"); else puts("NIE"); #ifdef __WIN32 system("pause"); #endif return 0; } |
English