#include <iostream> #include <list> #include <algorithm> using namespace std; struct company{ int minh, maxh, minw, maxw; bool operator==(company &comp) { return comp.minh == minh&&comp.maxh == maxh&&comp.minw == minw&&comp.maxw == maxw; } }; int main() { int t; cin >> t; for (int t1 = 0; t1 < t; t1++) { int n; cin >> n; company candidate; bool found = true; cin >> candidate.minw >> candidate.maxw >> candidate.minh >> candidate.maxh; for (int i = 1; i < n; i++) { company tmp; cin >> tmp.minw >> tmp.maxw >> tmp.minh >> tmp.maxh; if (tmp.minw <= candidate.minw && tmp.maxw >= candidate.maxw && tmp.minh <= candidate.minh && tmp.maxh >= candidate.maxh) { candidate = tmp; found = true; } else if (tmp.minw >= candidate.minw && tmp.maxw <= candidate.maxw && tmp.minh >= candidate.minh && tmp.maxh <= candidate.maxh) continue; else { candidate.minw = min(candidate.minw, tmp.minw); candidate.maxw = max(candidate.maxw, tmp.maxw); candidate.minh = min(candidate.minh, tmp.minh); candidate.maxh = max(candidate.maxh, tmp.maxh); found = false; } } if (found) cout << "TAK" << endl; else cout << "NIE" << 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 | #include <iostream> #include <list> #include <algorithm> using namespace std; struct company{ int minh, maxh, minw, maxw; bool operator==(company &comp) { return comp.minh == minh&&comp.maxh == maxh&&comp.minw == minw&&comp.maxw == maxw; } }; int main() { int t; cin >> t; for (int t1 = 0; t1 < t; t1++) { int n; cin >> n; company candidate; bool found = true; cin >> candidate.minw >> candidate.maxw >> candidate.minh >> candidate.maxh; for (int i = 1; i < n; i++) { company tmp; cin >> tmp.minw >> tmp.maxw >> tmp.minh >> tmp.maxh; if (tmp.minw <= candidate.minw && tmp.maxw >= candidate.maxw && tmp.minh <= candidate.minh && tmp.maxh >= candidate.maxh) { candidate = tmp; found = true; } else if (tmp.minw >= candidate.minw && tmp.maxw <= candidate.maxw && tmp.minh >= candidate.minh && tmp.maxh <= candidate.maxh) continue; else { candidate.minw = min(candidate.minw, tmp.minw); candidate.maxw = max(candidate.maxw, tmp.maxw); candidate.minh = min(candidate.minh, tmp.minh); candidate.maxh = max(candidate.maxh, tmp.maxh); found = false; } } if (found) cout << "TAK" << endl; else cout << "NIE" << endl; } return 0; } |