#include <cstdio> #include <algorithm> using namespace std; #define N 100010 #define INF 1000000001 bool success; int t, n, min_w1, max_w2, min_h1, max_h2; int w1[N], w2[N], h1[N], h2[N]; int main() { scanf("%d", &t); while(t--) { success = false; min_w1 = min_h1 = INF; max_w2 = max_h2 = -1; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d%d%d", w1+i, w2+i, h1+i, h2+i); min_w1 = min(min_w1, w1[i]); min_h1 = min(min_h1, h1[i]); max_w2 = max(max_w2, w2[i]); max_h2 = max(max_h2, h2[i]); } for (int i = 0; i < n; i++) { if (w1[i] == min_w1 && w2[i] == max_w2 && h1[i] == min_h1 && h2[i] == max_h2) { success = true; break; } } printf((success) ? "TAK\n" : "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 | #include <cstdio> #include <algorithm> using namespace std; #define N 100010 #define INF 1000000001 bool success; int t, n, min_w1, max_w2, min_h1, max_h2; int w1[N], w2[N], h1[N], h2[N]; int main() { scanf("%d", &t); while(t--) { success = false; min_w1 = min_h1 = INF; max_w2 = max_h2 = -1; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d%d%d", w1+i, w2+i, h1+i, h2+i); min_w1 = min(min_w1, w1[i]); min_h1 = min(min_h1, h1[i]); max_w2 = max(max_w2, w2[i]); max_h2 = max(max_h2, h2[i]); } for (int i = 0; i < n; i++) { if (w1[i] == min_w1 && w2[i] == max_w2 && h1[i] == min_h1 && h2[i] == max_h2) { success = true; break; } } printf((success) ? "TAK\n" : "NIE\n"); } return 0; } |