#include <cstdio> using namespace std; int main() { int t, n; scanf("%d", &t); int wMin, wMax, hMin, hMax; int w1, w2, h1, h2; bool major; while(t--){ scanf("%d", &n); wMin = 2e9; hMin = 2e9; wMax = -1; hMax = -1; major = true; while(n--){ scanf("%d", &w1); scanf("%d", &w2); scanf("%d", &h1); scanf("%d", &h2); if(w1 >= wMin && w2 <= wMax && h1 >= hMin && h2 <= hMax) continue; if(w1 <= wMin && w2 >= wMax && h1 <= hMin && h2 >= hMax){ wMin = w1; wMax = w2; hMin = h1; hMax = h2; major = true; } else{ if(w1 < wMin) wMin = w1; if(w2 > wMax) wMax = w2; if(h1 < hMin) hMin = h1; if(h2 > hMax) hMax = h2; major = false; } } if(major) printf("TAK\n"); else printf("NIE\n"); } }
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> using namespace std; int main() { int t, n; scanf("%d", &t); int wMin, wMax, hMin, hMax; int w1, w2, h1, h2; bool major; while(t--){ scanf("%d", &n); wMin = 2e9; hMin = 2e9; wMax = -1; hMax = -1; major = true; while(n--){ scanf("%d", &w1); scanf("%d", &w2); scanf("%d", &h1); scanf("%d", &h2); if(w1 >= wMin && w2 <= wMax && h1 >= hMin && h2 <= hMax) continue; if(w1 <= wMin && w2 >= wMax && h1 <= hMin && h2 >= hMax){ wMin = w1; wMax = w2; hMin = h1; hMax = h2; major = true; } else{ if(w1 < wMin) wMin = w1; if(w2 > wMax) wMax = w2; if(h1 < hMin) hMin = h1; if(h2 > hMax) hMax = h2; major = false; } } if(major) printf("TAK\n"); else printf("NIE\n"); } } |