#include <cstdio> #include <algorithm> #define LL long long using namespace std; const int INF = 1000000005; const int N = 1000005; int t, n; int wmin[N], wmax[N], hmin[N], hmax[N]; int minW, maxW, minH, maxH; bool major() { for(int i=1; i<=n; i++) if(wmin[i] == minW && wmax[i] == maxW && hmin[i] == minH && hmax[i] == maxH) return 1; return 0; } int main() { scanf("%d", &t); while(t--) { scanf("%d", &n); minW = minH = INF; maxW = maxH = -1; for(int i=1; i<=n; i++) { scanf("%d %d %d %d", &wmin[i], &wmax[i], &hmin[i], &hmax[i]); minW = min(minW, wmin[i]); minH = min(minH, hmin[i]); maxW = max(maxW, wmax[i]); maxH = max(maxH, hmax[i]); } printf(major()? "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 | #include <cstdio> #include <algorithm> #define LL long long using namespace std; const int INF = 1000000005; const int N = 1000005; int t, n; int wmin[N], wmax[N], hmin[N], hmax[N]; int minW, maxW, minH, maxH; bool major() { for(int i=1; i<=n; i++) if(wmin[i] == minW && wmax[i] == maxW && hmin[i] == minH && hmax[i] == maxH) return 1; return 0; } int main() { scanf("%d", &t); while(t--) { scanf("%d", &n); minW = minH = INF; maxW = maxH = -1; for(int i=1; i<=n; i++) { scanf("%d %d %d %d", &wmin[i], &wmax[i], &hmin[i], &hmax[i]); minW = min(minW, wmin[i]); minH = min(minH, hmin[i]); maxW = max(maxW, wmax[i]); maxH = max(maxH, hmax[i]); } printf(major()? "TAK\n": "NIE\n"); } return 0; } |