#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORB(i,b,n) for(int i=b;i<n;++i)
#define REV(i,n) for(int i=n;i>=0;--i)
#define FOREACH(T, it, v) for(T::iterator it = v.begin(); it !=v.end(); ++it)
#define print(STRING,INT) printf("%s= %d\n", STRING, INT)
#define scan(INT) scanf("%d", &INT)
typedef unsigned int u32;
const int INF = (0u - 11)/2;
typedef long long ll;
typedef set<int> SI;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef set<long long> SL;
typedef map<int, int> MII;
int DEBUG_ = 1;
void log(char* S, long long a)
{
if(DEBUG_)
{
printf("%s= %I64d\n", S, a);
}
}
int w1, w2, h1, h2;
int update(int a, int b, int c, int d)
{
int greater = 0;
int equal = 0;
if(a < w1)
{
greater++;
w1 = a;
}
if(a == w1) equal++;
if(b > w2)
{
greater++;
w2 = b;
}
if(b == w2) equal++;
if(c < h1)
{
greater++;
h1 = c;
}
if(c == h1) equal++;
if(d > h2)
{
greater++;
h2 = d;
}
if(d == h2) equal++;
if(equal == 4) return 2;
if(greater > 0) return 1;
return 0;
}
void solve()
{
int n;
scan(n);
scan(w1);
scan(w2);
scan(h1);
scan(h2);
int WIN = 1;
int a,b,c,d;
FORB(i,1,n)
{
scan(a);scan(b);scan(c);scan(d);
int A = update(a,b,c,d);
if(A == 2) WIN = 1;
else if(A == 1) WIN = 0;
}
if(WIN)
cout << "TAK" << endl;
else
cout << "NIE" << endl;
}
int main()
{
int T;
scan(T);
while(T--)
{
solve();
}
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; #define FOR(i,n) for(int i=0;i<n;++i) #define FORB(i,b,n) for(int i=b;i<n;++i) #define REV(i,n) for(int i=n;i>=0;--i) #define FOREACH(T, it, v) for(T::iterator it = v.begin(); it !=v.end(); ++it) #define print(STRING,INT) printf("%s= %d\n", STRING, INT) #define scan(INT) scanf("%d", &INT) typedef unsigned int u32; const int INF = (0u - 11)/2; typedef long long ll; typedef set<int> SI; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef set<long long> SL; typedef map<int, int> MII; int DEBUG_ = 1; void log(char* S, long long a) { if(DEBUG_) { printf("%s= %I64d\n", S, a); } } int w1, w2, h1, h2; int update(int a, int b, int c, int d) { int greater = 0; int equal = 0; if(a < w1) { greater++; w1 = a; } if(a == w1) equal++; if(b > w2) { greater++; w2 = b; } if(b == w2) equal++; if(c < h1) { greater++; h1 = c; } if(c == h1) equal++; if(d > h2) { greater++; h2 = d; } if(d == h2) equal++; if(equal == 4) return 2; if(greater > 0) return 1; return 0; } void solve() { int n; scan(n); scan(w1); scan(w2); scan(h1); scan(h2); int WIN = 1; int a,b,c,d; FORB(i,1,n) { scan(a);scan(b);scan(c);scan(d); int A = update(a,b,c,d); if(A == 2) WIN = 1; else if(A == 1) WIN = 0; } if(WIN) cout << "TAK" << endl; else cout << "NIE" << endl; } int main() { int T; scan(T); while(T--) { solve(); } return 0; } |
English