#include <stdio.h> #define INF 1000000001 //---------------------------------- void readInt(int *n) { register char c = 0; while (c < 48) c = getc_unlocked(stdin); (*n) = 0; while (c>32) { (*n)=(*n)*10 + (c-48); c=getc_unlocked(stdin); } } //------------------------------------ int main(void) { int i, j, k, n, t; int w1, w2, h1, h2, a1, a2, b1, b2; char F, G, H, I, res; readInt(&t); while(t--) { readInt(&n); a1=a2=INF; b1=b2=0; for(i=0; i<n; i++) { F=G=H=I=0; readInt(&w1); readInt(&w2); readInt(&h1); readInt(&h2); if(w1<=a1) { F=1; if(w1<a1) { a1=w1; F=3; } } if(h1<=a2) { G=1; if(h1<a2) { a2=h1; G=3; } } if(w2>=b1) { H=1; if(w2>b1) { b1=w2; H=3; } } if(h2>=b2) { I=1; if(h2>b2) { b2=h2; I=3; } } if(F && G && H && I) res = 1; else if(F+G>2 || H+I>2) res = 0; } if (res) puts("TAK"); else puts("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 44 45 46 47 | #include <stdio.h> #define INF 1000000001 //---------------------------------- void readInt(int *n) { register char c = 0; while (c < 48) c = getc_unlocked(stdin); (*n) = 0; while (c>32) { (*n)=(*n)*10 + (c-48); c=getc_unlocked(stdin); } } //------------------------------------ int main(void) { int i, j, k, n, t; int w1, w2, h1, h2, a1, a2, b1, b2; char F, G, H, I, res; readInt(&t); while(t--) { readInt(&n); a1=a2=INF; b1=b2=0; for(i=0; i<n; i++) { F=G=H=I=0; readInt(&w1); readInt(&w2); readInt(&h1); readInt(&h2); if(w1<=a1) { F=1; if(w1<a1) { a1=w1; F=3; } } if(h1<=a2) { G=1; if(h1<a2) { a2=h1; G=3; } } if(w2>=b1) { H=1; if(w2>b1) { b1=w2; H=3; } } if(h2>=b2) { I=1; if(h2>b2) { b2=h2; I=3; } } if(F && G && H && I) res = 1; else if(F+G>2 || H+I>2) res = 0; } if (res) puts("TAK"); else puts("NIE"); } return 0; } //---------------------------------- |