#include<cstdio> using namespace std; int t,n,i,j,ok; long long h_1,h_2,w_1,w_2,h_min,h_max,w_min,w_max; int main(){ scanf("%d",&t); while(t--){ ok=1; scanf("%d",&n); scanf("%lld%lld%lld%lld",&w_min,&w_max,&h_min,&h_max); n--; while(n--){ scanf("%lld%lld%lld%lld",&w_1,&w_2,&h_1,&h_2); if(!(w_1>=w_min&&w_2<=w_max&&h_1>=h_min&&h_2<=h_max)){ if(w_1<=w_min&&w_2>=w_max&&h_1<=h_min&&h_2>=h_max){ ok=1; w_min=w_1; w_max=w_2; h_min=h_1; h_max=h_2; }else{ ok=0; if(w_min>w_1)w_min=w_1; if(w_2>w_max)w_max=w_2; if(h_1<h_min)h_min=h_1; if(h_2>h_max)h_max=h_2; }}} if(ok) 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 | #include<cstdio> using namespace std; int t,n,i,j,ok; long long h_1,h_2,w_1,w_2,h_min,h_max,w_min,w_max; int main(){ scanf("%d",&t); while(t--){ ok=1; scanf("%d",&n); scanf("%lld%lld%lld%lld",&w_min,&w_max,&h_min,&h_max); n--; while(n--){ scanf("%lld%lld%lld%lld",&w_1,&w_2,&h_1,&h_2); if(!(w_1>=w_min&&w_2<=w_max&&h_1>=h_min&&h_2<=h_max)){ if(w_1<=w_min&&w_2>=w_max&&h_1<=h_min&&h_2>=h_max){ ok=1; w_min=w_1; w_max=w_2; h_min=h_1; h_max=h_2; }else{ ok=0; if(w_min>w_1)w_min=w_1; if(w_2>w_max)w_max=w_2; if(h_1<h_min)h_min=h_1; if(h_2>h_max)h_max=h_2; }}} if(ok) printf("TAK\n"); else printf("NIE\n"); } return 0; } |