#include <iostream> #include <algorithm> typedef unsigned int uint32; using namespace std; class Mirr { uint32 min_H, max_H, min_W, max_W; public: inline void GetFromInput() { scanf("%u%u%u%u", &min_W, &max_W, &min_H, &max_H); //cin >> min_W >> max_W >> min_H >> max_H; } inline bool Contains(const Mirr& x) { return min_H <= x.min_H && max_H >= x.max_H && min_W <= x.min_W && max_W >= x.max_W; } }; bool test() { Mirr current, current_best; uint32 n; //cin >> n; scanf("%u", &n); current.GetFromInput(); current_best = current; bool exists = true; for (uint32 i = 1; i < n; ++i) { current.GetFromInput(); if (!current_best.Contains(current)) { exists = false; if (current.Contains(current_best)) { current_best = current; exists = true; } } } return exists; } int main(int argc, char**argv) { uint32 t; cin >> t; for (uint32 i = 0; i < t; ++i) cout << (test() ? "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 | #include <iostream> #include <algorithm> typedef unsigned int uint32; using namespace std; class Mirr { uint32 min_H, max_H, min_W, max_W; public: inline void GetFromInput() { scanf("%u%u%u%u", &min_W, &max_W, &min_H, &max_H); //cin >> min_W >> max_W >> min_H >> max_H; } inline bool Contains(const Mirr& x) { return min_H <= x.min_H && max_H >= x.max_H && min_W <= x.min_W && max_W >= x.max_W; } }; bool test() { Mirr current, current_best; uint32 n; //cin >> n; scanf("%u", &n); current.GetFromInput(); current_best = current; bool exists = true; for (uint32 i = 1; i < n; ++i) { current.GetFromInput(); if (!current_best.Contains(current)) { exists = false; if (current.Contains(current_best)) { current_best = current; exists = true; } } } return exists; } int main(int argc, char**argv) { uint32 t; cin >> t; for (uint32 i = 0; i < t; ++i) cout << (test() ? "TAK" : "NIE") << "\n"; } |