#include <cstdio> using namespace std; const int INF = 0x7fffffff; void solve() { int n; scanf("%d", &n); int W1 = INF; int W2 = 0; int H1 = INF; int H2 = 0; bool res = false; while (n--) { int w1, w2, h1, h2; scanf("%d%d%d%d", &w1, &w2, &h1, &h2); if (w1 <= W1 && w2 >= W2 && h1 <= H1 && h2 >= H2) { W1 = w1; W2 = w2; H1 = h1; H2 = h2; res = true; } else if (w1 < W1) { W1 = w1; res = false; } else if (w2 > W2) { W2 = w2; res = false; } else if (h1 < H1) { H1 = h1; res = false; } else if (h2 > H2) { H2 = h2; res = false; } } printf("%s\n", res ? "TAK" : "NIE"); } int main() { int t; scanf("%d", &t); while (t--) { solve(); } 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 | #include <cstdio> using namespace std; const int INF = 0x7fffffff; void solve() { int n; scanf("%d", &n); int W1 = INF; int W2 = 0; int H1 = INF; int H2 = 0; bool res = false; while (n--) { int w1, w2, h1, h2; scanf("%d%d%d%d", &w1, &w2, &h1, &h2); if (w1 <= W1 && w2 >= W2 && h1 <= H1 && h2 >= H2) { W1 = w1; W2 = w2; H1 = h1; H2 = h2; res = true; } else if (w1 < W1) { W1 = w1; res = false; } else if (w2 > W2) { W2 = w2; res = false; } else if (h1 < H1) { H1 = h1; res = false; } else if (h2 > H2) { H2 = h2; res = false; } } printf("%s\n", res ? "TAK" : "NIE"); } int main() { int t; scanf("%d", &t); while (t--) { solve(); } return 0; } |