#include <iostream> struct offer { unsigned int _min_width; unsigned int _max_width; unsigned int _min_height; unsigned int _max_height; bool operator>=(const offer& other) { if ( _min_width <= other._min_width && _max_width >= other._max_width && _min_height <= other._min_height && _max_height >= other._max_height) { return true; } return false; } void merge(const offer& other) { _min_width = std::min(_min_width, other._min_width); _max_width = std::max(_max_width, other._max_width); _min_height = std::min(_min_height, other._min_height); _max_height = std::max(_max_height, other._max_height); } }; std::istream& operator>>(std::istream& stream, offer& o) { stream >> o._min_width >> o._max_width >> o._min_height >> o._max_height; return stream; } std::ostream& operator<<(std::ostream& stream, offer& o) { stream << o._min_width << o._max_width << o._min_height << o._max_height; return stream; } int main() { std::ios_base::sync_with_stdio(0); unsigned int test_cases; std::cin >> test_cases; for (unsigned int i = 0; i < test_cases; ++i) { unsigned int producers; std::cin >> producers; offer major; std::cin >> major; offer seen_major = major; for (unsigned int j = 1; j < producers; ++j) { offer current; std::cin >> current; major.merge(current); if (current >= major) { seen_major = major; } } if (seen_major >= major) { std::cout << "TAK" << std::endl; } else { std::cout << "NIE" << std::endl; } } 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #include <iostream> struct offer { unsigned int _min_width; unsigned int _max_width; unsigned int _min_height; unsigned int _max_height; bool operator>=(const offer& other) { if ( _min_width <= other._min_width && _max_width >= other._max_width && _min_height <= other._min_height && _max_height >= other._max_height) { return true; } return false; } void merge(const offer& other) { _min_width = std::min(_min_width, other._min_width); _max_width = std::max(_max_width, other._max_width); _min_height = std::min(_min_height, other._min_height); _max_height = std::max(_max_height, other._max_height); } }; std::istream& operator>>(std::istream& stream, offer& o) { stream >> o._min_width >> o._max_width >> o._min_height >> o._max_height; return stream; } std::ostream& operator<<(std::ostream& stream, offer& o) { stream << o._min_width << o._max_width << o._min_height << o._max_height; return stream; } int main() { std::ios_base::sync_with_stdio(0); unsigned int test_cases; std::cin >> test_cases; for (unsigned int i = 0; i < test_cases; ++i) { unsigned int producers; std::cin >> producers; offer major; std::cin >> major; offer seen_major = major; for (unsigned int j = 1; j < producers; ++j) { offer current; std::cin >> current; major.merge(current); if (current >= major) { seen_major = major; } } if (seen_major >= major) { std::cout << "TAK" << std::endl; } else { std::cout << "NIE" << std::endl; } } return 0; } |