#include <cstdio> #define FOREACH(n, i) for(int i=0;i<n;i++) #define MAX 1000000000 int main(){ int t, n, wmin, wmax, wminw, wmaxw, hmin, hmax, hminw, hmaxw, temp, temp1, temp2, temp3; scanf("%d", &t); FOREACH(t, place_holder){ scanf("%d", &n); wmin=MAX; wmax=0; wminw=MAX; wmaxw=0; hmin=MAX; hmax=0; hminw=MAX; hmaxw=0; FOREACH(n, i){ scanf("%d%d%d%d", &temp,&temp1,&temp2,&temp3); if(temp <= wmin && temp1 >= wmax && temp2 <= hmin && temp3 >= hmax){ wmin=temp; wmax=temp1; hmin=temp2; hmax=temp3; }else{ if(temp < wmin && temp < wminw) wminw=temp; if(temp1 > wmax && temp1 > wmaxw) wmaxw=temp1; if(temp2 < hmin && temp2 < hminw) hminw=temp2; if(temp3 > hmax && temp3 > hmaxw) hmaxw=temp3; } } printf(wminw>=wmin && wmaxw<=wmax && hmaxw<=hmax && hminw>=hmin ? "TAK\n":"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 | #include <cstdio> #define FOREACH(n, i) for(int i=0;i<n;i++) #define MAX 1000000000 int main(){ int t, n, wmin, wmax, wminw, wmaxw, hmin, hmax, hminw, hmaxw, temp, temp1, temp2, temp3; scanf("%d", &t); FOREACH(t, place_holder){ scanf("%d", &n); wmin=MAX; wmax=0; wminw=MAX; wmaxw=0; hmin=MAX; hmax=0; hminw=MAX; hmaxw=0; FOREACH(n, i){ scanf("%d%d%d%d", &temp,&temp1,&temp2,&temp3); if(temp <= wmin && temp1 >= wmax && temp2 <= hmin && temp3 >= hmax){ wmin=temp; wmax=temp1; hmin=temp2; hmax=temp3; }else{ if(temp < wmin && temp < wminw) wminw=temp; if(temp1 > wmax && temp1 > wmaxw) wmaxw=temp1; if(temp2 < hmin && temp2 < hminw) hminw=temp2; if(temp3 > hmax && temp3 > hmaxw) hmaxw=temp3; } } printf(wminw>=wmin && wmaxw<=wmax && hmaxw<=hmax && hminw>=hmin ? "TAK\n":"NIE\n"); } return 0; } |