// Karol Różycki Zadnanie Lustra #include<cstdio> #define MAX 100010 using namespace std; struct mirror{ long long int w1, w2, h1, h2; }; bool mycmp(const mirror& i, const mirror& j){ if(i.w2 * i.h2 != j.w2 * j.h2){ return i.w2 * i.h2 < j.w2 * j.h2; }else{ return -i.w1 * i.h1 < -j.w1 * j.h1; } } mirror MIRRORS[MAX]; int main(){ int t; scanf("%d", &t); while(t--){ int n; scanf("%d", &n); for(int i = 0; i < n; i++){ scanf("%lld %lld %lld %lld", &MIRRORS[i].w1, &MIRRORS[i].w2, &MIRRORS[i].h1, &MIRRORS[i].h2); } int index = -1; for(int i = 0; i < n; i++){ if(index == -1 || mycmp(MIRRORS[index], MIRRORS[i])){ index = i; } } bool covers_all = true; for(int i = 0; i < n; i++){ if(MIRRORS[i].w1 < MIRRORS[index].w1 || MIRRORS[i].w2 > MIRRORS[index].w2 || MIRRORS[i].h1 < MIRRORS[index].h1 || MIRRORS[i].h2 > MIRRORS[index].h2){ covers_all = false; break; } } if(covers_all){ 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 | // Karol Różycki Zadnanie Lustra #include<cstdio> #define MAX 100010 using namespace std; struct mirror{ long long int w1, w2, h1, h2; }; bool mycmp(const mirror& i, const mirror& j){ if(i.w2 * i.h2 != j.w2 * j.h2){ return i.w2 * i.h2 < j.w2 * j.h2; }else{ return -i.w1 * i.h1 < -j.w1 * j.h1; } } mirror MIRRORS[MAX]; int main(){ int t; scanf("%d", &t); while(t--){ int n; scanf("%d", &n); for(int i = 0; i < n; i++){ scanf("%lld %lld %lld %lld", &MIRRORS[i].w1, &MIRRORS[i].w2, &MIRRORS[i].h1, &MIRRORS[i].h2); } int index = -1; for(int i = 0; i < n; i++){ if(index == -1 || mycmp(MIRRORS[index], MIRRORS[i])){ index = i; } } bool covers_all = true; for(int i = 0; i < n; i++){ if(MIRRORS[i].w1 < MIRRORS[index].w1 || MIRRORS[i].w2 > MIRRORS[index].w2 || MIRRORS[i].h1 < MIRRORS[index].h1 || MIRRORS[i].h2 > MIRRORS[index].h2){ covers_all = false; break; } } if(covers_all){ printf("TAK\n"); }else{ printf("NIE\n"); } } return 0; } |