#include <cstdio> #include <algorithm> using namespace std; int t, n; int w1, w2, h1, h2; int wb1, wb2, hb1, hb2; bool isIn(int l1w1, int l1w2, int l1h1, int l1h2, int l2w1, int l2w2, int l2h1, int l2h2) { return l1w1 >= l2w1 && l1w2 <= l2w2 && l1h1 >= l2h1 && l1h2 <= l2h2; } bool solve() { bool ret = true; scanf("%d", &n); scanf("%d%d%d%d", &wb1, &wb2, &hb1, &hb2); for (int i = 1; i < n; i++) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); // new mirror size if (!isIn(w1, w2, h1, h2, wb1, wb2, hb1, hb2)) { ret = false; // Update max rect wb1 = min(wb1, w1); wb2 = max(wb2, w2); hb1 = min(hb1, h1); hb2 = max(hb2, h2); } // maybe it already covers all previous if (isIn(wb1, wb2, hb1, hb2, w1, w2, h1, h2)) { ret = true; } } return ret; } int main() { scanf("%d", &t); for (int i = 0; i < t; ++i) { printf(solve() ? "TAK\n" : "NIE\n"); } 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 47 48 49 50 51 52 | #include <cstdio> #include <algorithm> using namespace std; int t, n; int w1, w2, h1, h2; int wb1, wb2, hb1, hb2; bool isIn(int l1w1, int l1w2, int l1h1, int l1h2, int l2w1, int l2w2, int l2h1, int l2h2) { return l1w1 >= l2w1 && l1w2 <= l2w2 && l1h1 >= l2h1 && l1h2 <= l2h2; } bool solve() { bool ret = true; scanf("%d", &n); scanf("%d%d%d%d", &wb1, &wb2, &hb1, &hb2); for (int i = 1; i < n; i++) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); // new mirror size if (!isIn(w1, w2, h1, h2, wb1, wb2, hb1, hb2)) { ret = false; // Update max rect wb1 = min(wb1, w1); wb2 = max(wb2, w2); hb1 = min(hb1, h1); hb2 = max(hb2, h2); } // maybe it already covers all previous if (isIn(wb1, wb2, hb1, hb2, w1, w2, h1, h2)) { ret = true; } } return ret; } int main() { scanf("%d", &t); for (int i = 0; i < t; ++i) { printf(solve() ? "TAK\n" : "NIE\n"); } return 0; } |