#include<cstdio> #include<algorithm> struct Offer { int w1; int w2; int h1; int h2; }; const int N = 100000; const int infty = 1000000001; Offer offers[N]; int main(){ int t; scanf("%d", &t); while(t--){ int n; scanf("%d", &n); int w1 = infty; int w2 = -infty; int h1 = infty; int h2 = -infty; for(auto i = offers; i != offers + n; i++){ scanf("%d %d %d %d", &i->w1, &i->w2, &i->h1, &i->h2); w1 = std::min(w1, i->w1); w2 = std::max(w2, i->w2); h1 = std::min(h1, i->h1); h2 = std::max(h2, i->h2); } bool majorizing = false; for(auto i = offers; i != offers + n; i++) if(i->w1 == w1 && i->w2 == w2 && i->h1 == h1 && i->h2 == h2) majorizing = true; printf(majorizing ? "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 | #include<cstdio> #include<algorithm> struct Offer { int w1; int w2; int h1; int h2; }; const int N = 100000; const int infty = 1000000001; Offer offers[N]; int main(){ int t; scanf("%d", &t); while(t--){ int n; scanf("%d", &n); int w1 = infty; int w2 = -infty; int h1 = infty; int h2 = -infty; for(auto i = offers; i != offers + n; i++){ scanf("%d %d %d %d", &i->w1, &i->w2, &i->h1, &i->h2); w1 = std::min(w1, i->w1); w2 = std::max(w2, i->w2); h1 = std::min(h1, i->h1); h2 = std::max(h2, i->h2); } bool majorizing = false; for(auto i = offers; i != offers + n; i++) if(i->w1 == w1 && i->w2 == w2 && i->h1 == h1 && i->h2 == h2) majorizing = true; printf(majorizing ? "TAK\n" : "NIE\n"); } return 0; } |