#include <iostream> #include <climits> #include <algorithm> // std::min using namespace std; int main() { int t; scanf("%d", &t); while(t--) { int n, w1,w2,h1,h2,wmin=INT_MAX,wmax=INT_MIN,hmin=INT_MAX,hmax=INT_MIN; scanf("%d", &n); bool major = true; while(n--){ scanf("%d%d%d%d",&w1,&w2,&h1,&h2); if ( w1 <= wmin && w2 >= wmax && h1 <= hmin && h2 >= hmax ) { wmin = w1; wmax = w2; hmin = h1; hmax = h2; major = true; } else if ( !( w1 >= wmin && w2 <= wmax && h1 >= hmin && h2 <= hmax ) ) { wmin = min(wmin, w1); wmax = max(wmin, w2); hmin = min(hmin, h1); hmax = max(hmax, h2); major = false; } } if (major) { 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 | #include <iostream> #include <climits> #include <algorithm> // std::min using namespace std; int main() { int t; scanf("%d", &t); while(t--) { int n, w1,w2,h1,h2,wmin=INT_MAX,wmax=INT_MIN,hmin=INT_MAX,hmax=INT_MIN; scanf("%d", &n); bool major = true; while(n--){ scanf("%d%d%d%d",&w1,&w2,&h1,&h2); if ( w1 <= wmin && w2 >= wmax && h1 <= hmin && h2 >= hmax ) { wmin = w1; wmax = w2; hmin = h1; hmax = h2; major = true; } else if ( !( w1 >= wmin && w2 <= wmax && h1 >= hmin && h2 <= hmax ) ) { wmin = min(wmin, w1); wmax = max(wmin, w2); hmin = min(hmin, h1); hmax = max(hmax, h2); major = false; } } if (major) { printf("TAK\n"); } else { printf("NIE\n"); } } return 0; } |