#include <ctime> #include <bitset> #include <iterator> #include <string> #include <vector> #include <map> #include <list> #include <set> #include <queue> #include <iostream> #include <sstream> #include <stack> #include <deque> #include <cmath> #include <memory.h> #include <cstdlib> #include <cstdio> #include <cctype> #include <algorithm> #include <utility> using namespace std; #define PB push_back #define MP make_pair #define ALL(a) (a).begin(), (a).end() #define FILL(a,v) memset(a,v,sizeof(a)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define ABS(A) ((A) < 0 ? (-(A)) : (A)) #define SQR(x) (x)*(x) typedef long long ll; const double PI = acos(-1.0); const double EPS = 1e-7; const int INF = 2000000000; int a[100100][4]; int mx[4]; void solve() { int n; scanf("%d", &n); int i = 0; scanf("%d%d%d%d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]); mx[0]=a[0][0];mx[1]=a[0][1];mx[2]=a[0][2];mx[3]=a[0][3]; int ind = 0; for (i = 1; i < n; ++i) { scanf("%d%d%d%d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]); if (a[i][0]<mx[0])mx[0]=a[i][0]; if (a[i][2]<mx[2])mx[2]=a[i][2]; if (a[i][1]>mx[1])mx[1]=a[i][1]; if (a[i][3]>mx[3])mx[3]=a[i][3]; if (a[i][0]==mx[0] && a[i][1]==mx[1] && a[i][2]==mx[2] && a[i][3]==mx[3]) { ind = i; } } i=ind; if (a[i][0]==mx[0] && a[i][1]==mx[1] && a[i][2]==mx[2] && a[i][3]==mx[3]) { printf("TAK\n"); } else { printf("NIE\n"); } } int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); //clock_t st = clock(); int tests; scanf("%d", &tests); for (int test = 0; test < tests; ++test) { //clock_t stt = clock(); solve(); //cerr << test << ": " << (clock()-stt+0.0)/CLOCKS_PER_SEC << endl; } //cerr << "----\n" << (clock()-st+0.0)/CLOCKS_PER_SEC; 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 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | #include <ctime> #include <bitset> #include <iterator> #include <string> #include <vector> #include <map> #include <list> #include <set> #include <queue> #include <iostream> #include <sstream> #include <stack> #include <deque> #include <cmath> #include <memory.h> #include <cstdlib> #include <cstdio> #include <cctype> #include <algorithm> #include <utility> using namespace std; #define PB push_back #define MP make_pair #define ALL(a) (a).begin(), (a).end() #define FILL(a,v) memset(a,v,sizeof(a)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define ABS(A) ((A) < 0 ? (-(A)) : (A)) #define SQR(x) (x)*(x) typedef long long ll; const double PI = acos(-1.0); const double EPS = 1e-7; const int INF = 2000000000; int a[100100][4]; int mx[4]; void solve() { int n; scanf("%d", &n); int i = 0; scanf("%d%d%d%d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]); mx[0]=a[0][0];mx[1]=a[0][1];mx[2]=a[0][2];mx[3]=a[0][3]; int ind = 0; for (i = 1; i < n; ++i) { scanf("%d%d%d%d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]); if (a[i][0]<mx[0])mx[0]=a[i][0]; if (a[i][2]<mx[2])mx[2]=a[i][2]; if (a[i][1]>mx[1])mx[1]=a[i][1]; if (a[i][3]>mx[3])mx[3]=a[i][3]; if (a[i][0]==mx[0] && a[i][1]==mx[1] && a[i][2]==mx[2] && a[i][3]==mx[3]) { ind = i; } } i=ind; if (a[i][0]==mx[0] && a[i][1]==mx[1] && a[i][2]==mx[2] && a[i][3]==mx[3]) { printf("TAK\n"); } else { printf("NIE\n"); } } int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); //clock_t st = clock(); int tests; scanf("%d", &tests); for (int test = 0; test < tests; ++test) { //clock_t stt = clock(); solve(); //cerr << test << ": " << (clock()-stt+0.0)/CLOCKS_PER_SEC << endl; } //cerr << "----\n" << (clock()-st+0.0)/CLOCKS_PER_SEC; return 0; } |