#include <iostream> #include <climits> #include <algorithm> typedef unsigned int uint; enum status { TAK, NIE }; int main (int argc, char* argv[]) { uint t = 0, n = 0, w1 = 0, w2 = 0, h1 = 0, h2 = 0, w1min = UINT_MAX, w2max = 0, h1min = UINT_MAX, h2max = 0; status s = TAK; std::cin >> t; for (uint i = 0; i < t; ++i) { w1 = w2 = h1 = h2 = w2max = h2max = 0; w1min = h1min = UINT_MAX; std::cin >> n; for (uint j = 0; j < n; ++j) { std::cin >> w1 >> w2 >> h1 >> h2; if (w1 <= w1min && w2 >= w2max && h1 <= h1min && h2 >= h2max) { s = TAK; } else if (w1 < w1min || w2 > w2max || h1 < h1min || h2 > h2max) { s = NIE; } w1min = std::min(w1, w1min); w2max = std::max(w2, w2max); h1min = std::min(h1, h1min); h2max = std::max(h2, h2max); } if (s == TAK) { std::cout << "TAK\n"; } else { std::cout << "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 53 54 55 56 57 58 59 60 61 62 63 64 65 | #include <iostream> #include <climits> #include <algorithm> typedef unsigned int uint; enum status { TAK, NIE }; int main (int argc, char* argv[]) { uint t = 0, n = 0, w1 = 0, w2 = 0, h1 = 0, h2 = 0, w1min = UINT_MAX, w2max = 0, h1min = UINT_MAX, h2max = 0; status s = TAK; std::cin >> t; for (uint i = 0; i < t; ++i) { w1 = w2 = h1 = h2 = w2max = h2max = 0; w1min = h1min = UINT_MAX; std::cin >> n; for (uint j = 0; j < n; ++j) { std::cin >> w1 >> w2 >> h1 >> h2; if (w1 <= w1min && w2 >= w2max && h1 <= h1min && h2 >= h2max) { s = TAK; } else if (w1 < w1min || w2 > w2max || h1 < h1min || h2 > h2max) { s = NIE; } w1min = std::min(w1, w1min); w2max = std::max(w2, w2max); h1min = std::min(h1, h1min); h2max = std::max(h2, h2max); } if (s == TAK) { std::cout << "TAK\n"; } else { std::cout << "NIE\n"; } } return 0; } |