#include<cstdio> #define MAX 1000000010 using namespace std; int main() { int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); int w_mn=MAX, w_mx=0, h_mn=MAX, h_mx=0; int mx1=0,mx2=0,w3,w4,h3,h4; for(int i=0;i<n;i++) { int w1,w2,h1,h2; scanf("%d%d%d%d", &w1, &w2, &h1, &h2); if(w1<w_mn) w_mn=w1; if(w2>w_mx) w_mx=w2; if(h1<h_mn) h_mn=h1; if(h2>h_mx) h_mx=h2; if(w2-w1>=mx1 && h2-h1>=mx2){ mx1=w2-w1; mx2=h2-h1; w3=w1; w4=w2; h3=h1; h4=h2; } } //printf("%d %d %d %d\n%d %d %d %d\n", w3, w4, h3, h4, w_mn, w_mx, h_mn, h_mx); if(w3==w_mn && w4==w_mx && h3==h_mn && h4==h_mx) printf("TAK\n"); else printf("NIE\n"); } }
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 | #include<cstdio> #define MAX 1000000010 using namespace std; int main() { int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); int w_mn=MAX, w_mx=0, h_mn=MAX, h_mx=0; int mx1=0,mx2=0,w3,w4,h3,h4; for(int i=0;i<n;i++) { int w1,w2,h1,h2; scanf("%d%d%d%d", &w1, &w2, &h1, &h2); if(w1<w_mn) w_mn=w1; if(w2>w_mx) w_mx=w2; if(h1<h_mn) h_mn=h1; if(h2>h_mx) h_mx=h2; if(w2-w1>=mx1 && h2-h1>=mx2){ mx1=w2-w1; mx2=h2-h1; w3=w1; w4=w2; h3=h1; h4=h2; } } //printf("%d %d %d %d\n%d %d %d %d\n", w3, w4, h3, h4, w_mn, w_mx, h_mn, h_mx); if(w3==w_mn && w4==w_mx && h3==h_mn && h4==h_mx) printf("TAK\n"); else printf("NIE\n"); } } |