#include <cstdio> #include <algorithm> using namespace std; const int N = 1e5; const int INF = 1e9+1; int n, w1[N+1], w2[N+1], h1[N+1], h2[N+1]; int main() { int q; scanf("%d", &q); while (q--) { w1[0] = h1[0] = INF; w2[0] = h2[0] = -INF; scanf("%d", &n); for (int i=1; i<=n; ++i) { scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]); w1[0] = min(w1[0], w1[i]); w2[0] = max(w2[0], w2[i]); h1[0] = min(h1[0], h1[i]); h2[0] = max(h2[0], h2[i]); } bool ok = false; for (int i=1; !ok && i<=n; ++i) ok |= w1[i]==w1[0] && w2[i]==w2[0] && h1[i]==h1[0] && h2[i]==h2[0]; puts(ok ? "TAK" : "NIE"); } 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 | #include <cstdio> #include <algorithm> using namespace std; const int N = 1e5; const int INF = 1e9+1; int n, w1[N+1], w2[N+1], h1[N+1], h2[N+1]; int main() { int q; scanf("%d", &q); while (q--) { w1[0] = h1[0] = INF; w2[0] = h2[0] = -INF; scanf("%d", &n); for (int i=1; i<=n; ++i) { scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]); w1[0] = min(w1[0], w1[i]); w2[0] = max(w2[0], w2[i]); h1[0] = min(h1[0], h1[i]); h2[0] = max(h2[0], h2[i]); } bool ok = false; for (int i=1; !ok && i<=n; ++i) ok |= w1[i]==w1[0] && w2[i]==w2[0] && h1[i]==h1[0] && h2[i]==h2[0]; puts(ok ? "TAK" : "NIE"); } return 0; } |