#include <cstdio> #include <algorithm> using namespace std; int main() { int t, n; int w1, w2, h1, h2; int bw1, bw2, bh1, bh2; bool result; scanf("%d", &t); while (t--) { scanf("%d", &n); scanf("%d %d %d %d", &bw1, &bw2, &bh1, &bh2); result = true; --n; while (n--) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if (bw1 >= w1 && bw2 <= w2 && bh1 >= h1 && bh2 <= h2) { result = true; bw1 = w1; bw2 = w2; bh1 = h1; bh2 = h2; continue; } if (bw1 <= w1 && bw2 >= w2 && bh1 <= h1 && bh2 >= h2) { continue; } result = false; bw1 = min(bw1, w1); bw2 = max(bw2, w2); bh1 = min(bh1, h1); bh2 = max(bh2, h2); } printf("%s\n", result ? "TAK" : "NIE"); } 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 | #include <cstdio> #include <algorithm> using namespace std; int main() { int t, n; int w1, w2, h1, h2; int bw1, bw2, bh1, bh2; bool result; scanf("%d", &t); while (t--) { scanf("%d", &n); scanf("%d %d %d %d", &bw1, &bw2, &bh1, &bh2); result = true; --n; while (n--) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if (bw1 >= w1 && bw2 <= w2 && bh1 >= h1 && bh2 <= h2) { result = true; bw1 = w1; bw2 = w2; bh1 = h1; bh2 = h2; continue; } if (bw1 <= w1 && bw2 >= w2 && bh1 <= h1 && bh2 >= h2) { continue; } result = false; bw1 = min(bw1, w1); bw2 = max(bw2, w2); bh1 = min(bh1, h1); bh2 = max(bh2, h2); } printf("%s\n", result ? "TAK" : "NIE"); } return 0; } |