#include<stdio.h> int main(void) { int t; long long int n, i; long long int w1, w2, h1, h2; long long int wMin, wMax, hMin, hMax; int isWinner; scanf("%d",&t); while(t--) { scanf("%lld",&n); scanf("%lld %lld %lld %lld",&wMin,&wMax,&hMin,&hMax); isWinner = 1; for(i=2; i<=n;i++) { scanf("%lld %lld %lld %lld",&w1,&w2,&h1,&h2); if(w1<=wMin&&w2>=wMax&&h1<=hMin&&h2>=hMax) { isWinner = 1; wMin = w1; wMax = w2; hMin = h1; hMax = h2; } else if(w1>=wMin&&w2<=wMax&&h1>=hMin&&h2<=hMax) { //tu nic sie nie zmienia } else { isWinner = 0; if(w1<wMin) wMin = w1; if(w2>wMax) wMax = w2; if(h1<hMin) hMin = h1; if(h2>hMax) hMax = h2; } } if(isWinner == 1) { 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 | #include<stdio.h> int main(void) { int t; long long int n, i; long long int w1, w2, h1, h2; long long int wMin, wMax, hMin, hMax; int isWinner; scanf("%d",&t); while(t--) { scanf("%lld",&n); scanf("%lld %lld %lld %lld",&wMin,&wMax,&hMin,&hMax); isWinner = 1; for(i=2; i<=n;i++) { scanf("%lld %lld %lld %lld",&w1,&w2,&h1,&h2); if(w1<=wMin&&w2>=wMax&&h1<=hMin&&h2>=hMax) { isWinner = 1; wMin = w1; wMax = w2; hMin = h1; hMax = h2; } else if(w1>=wMin&&w2<=wMax&&h1>=hMin&&h2<=hMax) { //tu nic sie nie zmienia } else { isWinner = 0; if(w1<wMin) wMin = w1; if(w2>wMax) wMax = w2; if(h1<hMin) hMin = h1; if(h2>hMax) hMax = h2; } } if(isWinner == 1) { printf("TAK\n"); } else { printf("NIE\n"); } } return 0; } |