#include <iostream> #include <algorithm> using namespace std; struct Oferta { int w1, w2; int h1, h2; }; bool operatorPorownania(const Oferta &o1, const Oferta &o2) { if (o1.w1 == o2.w1) { if (o1.w2 == o2.w2) { if (o1.h1 == o2.h1) { if (o1.h2 >= o2.h2) return true; else return false; } else return o1.h1 < o2.h1; } else return o1.w2 > o2.w2; } else return o1.w1 < o2.w1; } int main() { int t,n; scanf("%d", &t); while (t--) { scanf("%d", &n); Oferta oferty[n]; for (int i=0; i<n; ++i) { scanf("%d %d %d %d", &oferty[i].w1, &oferty[i].w2, &oferty[i].h1, &oferty[i].h2); } sort(oferty, oferty+n, operatorPorownania); bool result = true; for (int i=1; i<n; ++i) { if ((oferty[i].w1 < oferty[0].w1) || (oferty[i].w2 > oferty[0].w2) || (oferty[i].h1 < oferty[0].h1) || (oferty[i].h2 > oferty[0].h2)) { result = false; break; } } if (result) 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 58 59 60 61 62 63 64 65 66 67 | #include <iostream> #include <algorithm> using namespace std; struct Oferta { int w1, w2; int h1, h2; }; bool operatorPorownania(const Oferta &o1, const Oferta &o2) { if (o1.w1 == o2.w1) { if (o1.w2 == o2.w2) { if (o1.h1 == o2.h1) { if (o1.h2 >= o2.h2) return true; else return false; } else return o1.h1 < o2.h1; } else return o1.w2 > o2.w2; } else return o1.w1 < o2.w1; } int main() { int t,n; scanf("%d", &t); while (t--) { scanf("%d", &n); Oferta oferty[n]; for (int i=0; i<n; ++i) { scanf("%d %d %d %d", &oferty[i].w1, &oferty[i].w2, &oferty[i].h1, &oferty[i].h2); } sort(oferty, oferty+n, operatorPorownania); bool result = true; for (int i=1; i<n; ++i) { if ((oferty[i].w1 < oferty[0].w1) || (oferty[i].w2 > oferty[0].w2) || (oferty[i].h1 < oferty[0].h1) || (oferty[i].h2 > oferty[0].h2)) { result = false; break; } } if (result) printf("TAK\n"); else printf("NIE\n"); } return 0; } |