#include <stdio.h> #define lowest 0 #define highest 1000000001 int main() { int t,n,w1,w2,h1,h2,i,j,k,Wmax, Wmin, Hmax, Hmin, Winner; scanf(" %d",&t); for(i=0; i<t; i++){ Wmax= lowest; Wmin= highest; Hmax= lowest; Hmin = highest; Winner = 0; scanf(" %d",&n); for(j=0; j<n; j++){ scanf(" %d %d %d %d",&w1,&w2,&h1,&h2); if((w1<=w2)&&(h1<=h2)) { //printf("wl, w2, h1, h2: %d %d %d %d\n", Wmin, Wmax, Hmin, Hmax); if(w1<Wmin) { Wmin = w1; Winner = 0; //printf("0 - Wmin\n"); } if(w2>Wmax) { Wmax = w2; Winner = 0; //printf("0 - Wmax \n"); } if(h1<Hmin) { Hmin = h1; Winner = 0; //printf("0 - Hmin\n"); } if(h2>Hmax) { Hmax = h2; Winner = 0; //printf("0 - Hmax\n"); } if((w1==Wmin)&&(w2==Wmax)&&(h1==Hmin)&&(h2==Hmax)) { Winner = 1; //printf("Found: j: %d\n",j); } } } if(Winner == 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 50 | #include <stdio.h> #define lowest 0 #define highest 1000000001 int main() { int t,n,w1,w2,h1,h2,i,j,k,Wmax, Wmin, Hmax, Hmin, Winner; scanf(" %d",&t); for(i=0; i<t; i++){ Wmax= lowest; Wmin= highest; Hmax= lowest; Hmin = highest; Winner = 0; scanf(" %d",&n); for(j=0; j<n; j++){ scanf(" %d %d %d %d",&w1,&w2,&h1,&h2); if((w1<=w2)&&(h1<=h2)) { //printf("wl, w2, h1, h2: %d %d %d %d\n", Wmin, Wmax, Hmin, Hmax); if(w1<Wmin) { Wmin = w1; Winner = 0; //printf("0 - Wmin\n"); } if(w2>Wmax) { Wmax = w2; Winner = 0; //printf("0 - Wmax \n"); } if(h1<Hmin) { Hmin = h1; Winner = 0; //printf("0 - Hmin\n"); } if(h2>Hmax) { Hmax = h2; Winner = 0; //printf("0 - Hmax\n"); } if((w1==Wmin)&&(w2==Wmax)&&(h1==Hmin)&&(h2==Hmax)) { Winner = 1; //printf("Found: j: %d\n",j); } } } if(Winner == 1) printf("TAK\n"); else printf("NIE\n"); } return 0; } |