#include <iostream> #include <math.h> #include <algorithm> #include <vector> #define For(i, n) for (int i = 0; i < (n); i++) #define ForD(i, n) for (int i = (n) - 1; i >= 0; i--) #define in cin>> #define out cout<< #define pb push_back #define mp make_pair using namespace std; struct fourth { int a, b, c, d; bool intersects(fourth source) { return a <= source.a && b >= source.b && c <= source.c && d >= source.d; } fourth(bool _read = false) { if (_read) read(); else a = b = c = d = 0; } void read() { in a >> b >> c >> d; } void include(fourth source) { a = min(a, source.a); b = max(b, source.b); c = min(c, source.c); d = max(d, source.d); } }; int main() { ios_base::sync_with_stdio(); int t; in t; while (t--) { int n; in n; fourth best(true); bool ans = true, done = true; For (i, n - 1) { fourth curr(true); if ((done && best.intersects(curr)) || (curr.intersects(best))) ans = true; else done = ans = false; best.include(curr); } out (ans ? "TAK\n" : "NIE\n"); } return 0; //system("pause"); }
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #include <iostream> #include <math.h> #include <algorithm> #include <vector> #define For(i, n) for (int i = 0; i < (n); i++) #define ForD(i, n) for (int i = (n) - 1; i >= 0; i--) #define in cin>> #define out cout<< #define pb push_back #define mp make_pair using namespace std; struct fourth { int a, b, c, d; bool intersects(fourth source) { return a <= source.a && b >= source.b && c <= source.c && d >= source.d; } fourth(bool _read = false) { if (_read) read(); else a = b = c = d = 0; } void read() { in a >> b >> c >> d; } void include(fourth source) { a = min(a, source.a); b = max(b, source.b); c = min(c, source.c); d = max(d, source.d); } }; int main() { ios_base::sync_with_stdio(); int t; in t; while (t--) { int n; in n; fourth best(true); bool ans = true, done = true; For (i, n - 1) { fourth curr(true); if ((done && best.intersects(curr)) || (curr.intersects(best))) ans = true; else done = ans = false; best.include(curr); } out (ans ? "TAK\n" : "NIE\n"); } return 0; //system("pause"); } |