#include<stdio.h> #define max(a,b) ( ((a) > (b))?(a):(b)) #define min(a,b) ( ((a) < (b))?(a):(b)) int main(){ int t; scanf("%i", &t); for(;t!=0;--t) { int n; scanf("%i", &n); int W1, W2, H1, H2; scanf("%i %i %i %i", &W1, &W2, &H1, &H2); bool major = true; for(--n; n!=0; --n) { int w1,w2,h1,h2; scanf("%i %i %i %i", &w1, &w2, &h1, &h2); if(w1 <= W1 && w2 >= W2 && h1 <= H1 && h2 >=H2) { major = true; } else if ( ! (w1 >= W1 && w2 <= W2 && h1 >= H1 && h2 <=H2) ) { major = false; } W1 = min(W1,w1); W2 = max(W2,w2); H1 = min(H1,h1); H2 = max(H2,h2); } printf(major ? "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 | #include<stdio.h> #define max(a,b) ( ((a) > (b))?(a):(b)) #define min(a,b) ( ((a) < (b))?(a):(b)) int main(){ int t; scanf("%i", &t); for(;t!=0;--t) { int n; scanf("%i", &n); int W1, W2, H1, H2; scanf("%i %i %i %i", &W1, &W2, &H1, &H2); bool major = true; for(--n; n!=0; --n) { int w1,w2,h1,h2; scanf("%i %i %i %i", &w1, &w2, &h1, &h2); if(w1 <= W1 && w2 >= W2 && h1 <= H1 && h2 >=H2) { major = true; } else if ( ! (w1 >= W1 && w2 <= W2 && h1 >= H1 && h2 <=H2) ) { major = false; } W1 = min(W1,w1); W2 = max(W2,w2); H1 = min(H1,h1); H2 = max(H2,h2); } printf(major ? "TAK\n" : "NIE\n"); } return 0; } |