#include <cstdio> #include <vector> #include <set> #include <functional> #define PB push_back #define MP make_pair #define FI first #define SE second #define MAX_N 100001 using namespace std; typedef pair<pair<int, int>, pair<int, int> > p; int main() { int t; scanf("%d", &t); vector<p> V; while(t--) { int n, a, b, c, d; int hl = MAX_N, hr = 0, wl = MAX_N, wr = 0; V.clear(); scanf("%d", &n); while(n--) { scanf("%d%d%d%d", &a, &b, &c, &d); hl = min(hl, a); hr = max(hr, b); wl = min(wl, c); wr = max(wr, d); if(wl == c && wr == d && hl == a && hr == b) { V.clear(); V.PB(MP(MP(a, b), MP(c, d))); } } bool fin = false; for(int i = 0; i < V.size(); i++) { p current = V[i]; fin |= current.FI.FI == hl && current.FI.SE == hr && current.SE.FI == wl && current.SE.SE == wr; if(fin) break; } if(fin) printf("TAK\n"); else printf("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 46 47 48 49 50 51 52 53 54 55 56 57 | #include <cstdio> #include <vector> #include <set> #include <functional> #define PB push_back #define MP make_pair #define FI first #define SE second #define MAX_N 100001 using namespace std; typedef pair<pair<int, int>, pair<int, int> > p; int main() { int t; scanf("%d", &t); vector<p> V; while(t--) { int n, a, b, c, d; int hl = MAX_N, hr = 0, wl = MAX_N, wr = 0; V.clear(); scanf("%d", &n); while(n--) { scanf("%d%d%d%d", &a, &b, &c, &d); hl = min(hl, a); hr = max(hr, b); wl = min(wl, c); wr = max(wr, d); if(wl == c && wr == d && hl == a && hr == b) { V.clear(); V.PB(MP(MP(a, b), MP(c, d))); } } bool fin = false; for(int i = 0; i < V.size(); i++) { p current = V[i]; fin |= current.FI.FI == hl && current.FI.SE == hr && current.SE.FI == wl && current.SE.SE == wr; if(fin) break; } if(fin) printf("TAK\n"); else printf("NIE\n"); } return 0; } |