#include <iostream> using namespace std; typedef long long unsigned LLU; int main() { int t; LLU n; LLU minw, maxw, minh, maxh; LLU miw, maw, mih, mah; cin >> t; while (t--) { bool exists=false; minw=minh=1000000001; maxw=maxh=0; cin >> n; while (n--) { cin >> miw; if (minw > miw) { minw=miw; exists=false; } cin >> maw; if (maxw < maw) { maxw=maw; exists=false; } cin >> mih; if (minh > mih) { minh=mih; exists=false; } cin >> mah; if (maxh < mah) { maxh=mah; exists=false; } if (!exists) if ((miw <= minw) && (maw >= maxw) && (mih <= minh) && (mah>=maxh)) exists=true; } if (exists) 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 | #include <iostream> using namespace std; typedef long long unsigned LLU; int main() { int t; LLU n; LLU minw, maxw, minh, maxh; LLU miw, maw, mih, mah; cin >> t; while (t--) { bool exists=false; minw=minh=1000000001; maxw=maxh=0; cin >> n; while (n--) { cin >> miw; if (minw > miw) { minw=miw; exists=false; } cin >> maw; if (maxw < maw) { maxw=maw; exists=false; } cin >> mih; if (minh > mih) { minh=mih; exists=false; } cin >> mah; if (maxh < mah) { maxh=mah; exists=false; } if (!exists) if ((miw <= minw) && (maw >= maxw) && (mih <= minh) && (mah>=maxh)) exists=true; } if (exists) cout << "TAK" << endl; else cout << "NIE" << endl; } return 0; } |