#include <algorithm> #include <cstdio> using namespace std; #define REP(i,n) for (int i = 0; i < (n); ++i) const int INF = 2000000000; int w1[100000], w2[100000], h1[100000], h2[100000]; int main() { int t; scanf("%d", &t); REP(tt,t) { int n; scanf("%d", &n); int mh1 = INF, mh2 = -INF, mw1 = INF, mw2 = -INF; REP(i,n) { scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]); mw1 = min(mw1, w1[i]); mw2 = max(mw2, w2[i]); mh1 = min(mh1, h1[i]); mh2 = max(mh2, h2[i]); } bool ok = 0; REP(i,n) if (w1[i] == mw1 && w2[i] == mw2 && h1[i] == mh1 && h2[i] == mh2) { ok = 1; break; } printf(ok ? "TAK\n" : "NIE\n"); } }
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 | #include <algorithm> #include <cstdio> using namespace std; #define REP(i,n) for (int i = 0; i < (n); ++i) const int INF = 2000000000; int w1[100000], w2[100000], h1[100000], h2[100000]; int main() { int t; scanf("%d", &t); REP(tt,t) { int n; scanf("%d", &n); int mh1 = INF, mh2 = -INF, mw1 = INF, mw2 = -INF; REP(i,n) { scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]); mw1 = min(mw1, w1[i]); mw2 = max(mw2, w2[i]); mh1 = min(mh1, h1[i]); mh2 = max(mh2, h2[i]); } bool ok = 0; REP(i,n) if (w1[i] == mw1 && w2[i] == mw2 && h1[i] == mh1 && h2[i] == mh2) { ok = 1; break; } printf(ok ? "TAK\n" : "NIE\n"); } } |