#include <iostream> #include <vector> #include <algorithm> using namespace std; const int INF = 1000000100; int main() { int t; cin >> t; while (t--) { int n; cin >> n; bool res = false; int aa = INF, bb = 0, cc = INF, dd = 0; int a, b, c, d; for (int i=0; i<n; i++) { cin >> a >> b >> c >> d; if (a <= aa && b >= bb && c <= cc && d >= dd) { res = true; aa = a; bb = b; cc = c; dd = d; } else if (a < aa || b > bb || c < cc || d > dd) { res = false; aa = min(aa, a); bb = max(bb, b); cc = min(cc, c); dd = max(dd, d); } } cout << (res ? "TAK" : "NIE") << endl; } }
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 | #include <iostream> #include <vector> #include <algorithm> using namespace std; const int INF = 1000000100; int main() { int t; cin >> t; while (t--) { int n; cin >> n; bool res = false; int aa = INF, bb = 0, cc = INF, dd = 0; int a, b, c, d; for (int i=0; i<n; i++) { cin >> a >> b >> c >> d; if (a <= aa && b >= bb && c <= cc && d >= dd) { res = true; aa = a; bb = b; cc = c; dd = d; } else if (a < aa || b > bb || c < cc || d > dd) { res = false; aa = min(aa, a); bb = max(bb, b); cc = min(cc, c); dd = max(dd, d); } } cout << (res ? "TAK" : "NIE") << endl; } } |