//Dominik Klemba #include <cstdio> #include <vector> #include <tuple> using namespace std; typedef tuple<unsigned, unsigned, unsigned, unsigned> prostokat; const bool sprawdz(const vector<prostokat>); int main() { unsigned t; scanf("%u",&t); for(unsigned i = 0; i < t; ++i) { unsigned n; scanf("%u", &n); vector<prostokat> dane(n); for(auto& x : dane) scanf("%u%u%u%u", &get<0>(x), &get<1>(x), &get<2>(x), &get<3>(x)); printf("%s\n",sprawdz(move(dane))? "TAK" : "NIE" ); } } const bool sprawdz(const vector<prostokat> prostokaty) { const auto& temp = prostokaty.front(); unsigned w_min = get<0>(temp),w_max = get<1>(temp),h_min = get<2>(temp),h_max = get<3>(temp); for(const auto& x : prostokaty) { w_min = min(w_min, get<0>(x)); w_max = max(w_max, get<1>(x)); h_min = min(h_min, get<2>(x)); h_max = max(h_max, get<3>(x)); } for(const auto& x : prostokaty) { if(get<0>(x) <= w_min && get<1>(x) >= w_max && get<2>(x) <= h_min && get<3>(x) >= h_max) { return true; } } return false; }
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 | //Dominik Klemba #include <cstdio> #include <vector> #include <tuple> using namespace std; typedef tuple<unsigned, unsigned, unsigned, unsigned> prostokat; const bool sprawdz(const vector<prostokat>); int main() { unsigned t; scanf("%u",&t); for(unsigned i = 0; i < t; ++i) { unsigned n; scanf("%u", &n); vector<prostokat> dane(n); for(auto& x : dane) scanf("%u%u%u%u", &get<0>(x), &get<1>(x), &get<2>(x), &get<3>(x)); printf("%s\n",sprawdz(move(dane))? "TAK" : "NIE" ); } } const bool sprawdz(const vector<prostokat> prostokaty) { const auto& temp = prostokaty.front(); unsigned w_min = get<0>(temp),w_max = get<1>(temp),h_min = get<2>(temp),h_max = get<3>(temp); for(const auto& x : prostokaty) { w_min = min(w_min, get<0>(x)); w_max = max(w_max, get<1>(x)); h_min = min(h_min, get<2>(x)); h_max = max(h_max, get<3>(x)); } for(const auto& x : prostokaty) { if(get<0>(x) <= w_min && get<1>(x) >= w_max && get<2>(x) <= h_min && get<3>(x) >= h_max) { return true; } } return false; } |