#include <cstdio> #include <algorithm> int main() { int T; scanf("%d ", &T); for (auto t = 0; t < T; t++) { int N; scanf("%d ", &N); int W1, W2, H1, H2; bool major = true; scanf("%d %d %d %d ", &W1, &W2, &H1, &H2); for (auto n = 1; n < N; n++) { int w1, w2, h1, h2; scanf("%d %d %d %d ", &w1, &w2, &h1, &h2); if (w1 < W1 || w2 > W2 || h1 < H1 || h2 > H2) { major = false; } W1 = std::min(w1, W1); W2 = std::max(w2, W2); H1 = std::min(h1, H1); H2 = std::max(h2, H2); if (w1<=W1 && w2>=W2 && h1<=H1 && h2>=H2) { major = true; } } printf("%s\n", major ? "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 | #include <cstdio> #include <algorithm> int main() { int T; scanf("%d ", &T); for (auto t = 0; t < T; t++) { int N; scanf("%d ", &N); int W1, W2, H1, H2; bool major = true; scanf("%d %d %d %d ", &W1, &W2, &H1, &H2); for (auto n = 1; n < N; n++) { int w1, w2, h1, h2; scanf("%d %d %d %d ", &w1, &w2, &h1, &h2); if (w1 < W1 || w2 > W2 || h1 < H1 || h2 > H2) { major = false; } W1 = std::min(w1, W1); W2 = std::max(w2, W2); H1 = std::min(h1, H1); H2 = std::max(h2, H2); if (w1<=W1 && w2>=W2 && h1<=H1 && h2>=H2) { major = true; } } printf("%s\n", major ? "TAK" : "NIE"); } return 0; } |