#include <iostream> using namespace std; struct oferta { int w1, w2, h1, h2; }; const int MAXN = 100000; oferta o[MAXN]; int main() { ios_base::sync_with_stdio(0); int t; cin >> t; while(t--) { int n; cin >> n; for(int i=0; i<n; i++) cin >> o[i].w1 >> o[i].w2 >> o[i].h1 >> o[i].h2; int minH = 2000000000, maxH = 0, minW = 2000000000, maxW = 0; for(int i=0; i<n; i++) minH = min(minH, o[i].h1), maxH = max(maxH, o[i].h2), minW = min(minW, o[i].w1), maxW = max(maxW, o[i].w2); bool exists = false; for(int i=0; i<n; i++) if(o[i].w1 <= minW && o[i].w2 >= maxW && o[i].h1 <= minH && o[i].h2 >= maxH) exists = true; if(exists) cout << "TAK\n"; else 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 | #include <iostream> using namespace std; struct oferta { int w1, w2, h1, h2; }; const int MAXN = 100000; oferta o[MAXN]; int main() { ios_base::sync_with_stdio(0); int t; cin >> t; while(t--) { int n; cin >> n; for(int i=0; i<n; i++) cin >> o[i].w1 >> o[i].w2 >> o[i].h1 >> o[i].h2; int minH = 2000000000, maxH = 0, minW = 2000000000, maxW = 0; for(int i=0; i<n; i++) minH = min(minH, o[i].h1), maxH = max(maxH, o[i].h2), minW = min(minW, o[i].w1), maxW = max(maxW, o[i].w2); bool exists = false; for(int i=0; i<n; i++) if(o[i].w1 <= minW && o[i].w2 >= maxW && o[i].h1 <= minH && o[i].h2 >= maxH) exists = true; if(exists) cout << "TAK\n"; else cout << "NIE\n"; } return 0; } |