#include <cstdio> typedef struct { int wMin,wMax,hMin,hMax; } Rect; bool test() { bool result=true; int n; Rect m,S; scanf("%d",&n); scanf("%d%d%d%d",&S.wMin, &S.wMax, &S.hMin, &S.hMax); while (--n) { scanf("%d%d%d%d",&m.wMin, &m.wMax, &m.hMin, &m.hMax); if (m.wMin<S.wMin) {result=false; S.wMin=m.wMin;} if (m.wMax>S.wMax) {result=false; S.wMax=m.wMax;} if (m.hMin<S.hMin) {result=false; S.hMin=m.hMin;} if (m.hMax>S.hMax) {result=false; S.hMax=m.hMax;} if (S.wMin==m.wMin && S.wMax==m.wMax && S.hMin==m.hMin && S.hMax==m.hMax) result=true; } return result; } int main() { int t; scanf("%d",&t); while (t--) puts(test() ? "TAK" : "NIE"); 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 | #include <cstdio> typedef struct { int wMin,wMax,hMin,hMax; } Rect; bool test() { bool result=true; int n; Rect m,S; scanf("%d",&n); scanf("%d%d%d%d",&S.wMin, &S.wMax, &S.hMin, &S.hMax); while (--n) { scanf("%d%d%d%d",&m.wMin, &m.wMax, &m.hMin, &m.hMax); if (m.wMin<S.wMin) {result=false; S.wMin=m.wMin;} if (m.wMax>S.wMax) {result=false; S.wMax=m.wMax;} if (m.hMin<S.hMin) {result=false; S.hMin=m.hMin;} if (m.hMax>S.hMax) {result=false; S.hMax=m.hMax;} if (S.wMin==m.wMin && S.wMax==m.wMax && S.hMin==m.hMin && S.hMax==m.hMax) result=true; } return result; } int main() { int t; scanf("%d",&t); while (t--) puts(test() ? "TAK" : "NIE"); return 0; } |