#include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); const int MAX = 1000000000; int t, n; int w1, w2, h1, h2; int wmin, wmax, hmin, hmax; bool maj; int c; cin >> t; while (t--) { cin >> n; wmin = MAX; wmax = 0; hmin = MAX; hmax = 0; maj = false; while (n--) { cin >> w1 >> w2 >> h1 >> h2; if (maj) { c = 0; if ((w1 < wmin) || (w2 > wmax) || (h1 < hmin) || (h2 > hmax)) maj = false; } if (!maj) { c = 0; if (w1 <= wmin) { wmin = w1; ++c; } if (w2 >= wmax) { wmax = w2; ++c; } if (h1 <= hmin) { hmin = h1; ++c; } if (h2 >= hmax) { hmax = h2; ++c; } if (c == 4) maj = true; } } cout << (maj ? "TAK" : "NIE") << '\n'; } }
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 53 54 55 56 57 58 59 60 61 62 63 | #include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); const int MAX = 1000000000; int t, n; int w1, w2, h1, h2; int wmin, wmax, hmin, hmax; bool maj; int c; cin >> t; while (t--) { cin >> n; wmin = MAX; wmax = 0; hmin = MAX; hmax = 0; maj = false; while (n--) { cin >> w1 >> w2 >> h1 >> h2; if (maj) { c = 0; if ((w1 < wmin) || (w2 > wmax) || (h1 < hmin) || (h2 > hmax)) maj = false; } if (!maj) { c = 0; if (w1 <= wmin) { wmin = w1; ++c; } if (w2 >= wmax) { wmax = w2; ++c; } if (h1 <= hmin) { hmin = h1; ++c; } if (h2 >= hmax) { hmax = h2; ++c; } if (c == 4) maj = true; } } cout << (maj ? "TAK" : "NIE") << '\n'; } } |