//Karol Kaszuba
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double D;
typedef long double LD;
typedef vector<PII> VII;
#define FOR(i,x,y) for(int i=(x);i<=(y);++i)
#define REP(i,x) FOR(i,0,(x)-1)
#define FORD(i,x,y) for(int i=(x);i>=(y);--i)
#define VAR(i,c) __typeof(c) i=(c)
#define FORE(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define SIZE(c) (int)((c).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN insert
#define ER erase
#define MP make_pair
#define ST first
#define ND second
#define IOSYNC ios_base::sync_with_stdio(0)
struct dupa
{
int a,b,c,d;
};
bool operator< (const dupa &x, const dupa &y)
{
if(x.a != y.a) return x.a < y.a;
if(x.b != y.b) return x.b > y.b;
if(x.c != y.c) return x.c < y.c;
if(x.d != y.d) return x.d > y.d;
}
dupa tab[100005];
bool jebaj()
{
int n;
cin >> n;
REP(i, n)
cin >> tab[i].a >> tab[i].b >> tab[i].c >> tab[i].d;
sort(tab, tab + n);
FOR(i, 1, n - 1)
{
if(tab[i].c < tab[0].c || tab[i].d > tab[0].d)
return false;
}
return true;
}
int main()
{
IOSYNC;
int t;
//t = 1;
cin >> t;
REP(i, t)
{
if(jebaj())
cout << "TAK\n";
else
cout << "NIE\n";
}
}
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 | //Karol Kaszuba #include <iostream> #include <iomanip> #include <cstdio> #include <algorithm> #include <cmath> #include <set> #include <map> #include <vector> #include <cstdlib> #include <ctime> using namespace std; typedef long long LL; typedef vector<int> VI; typedef pair<int,int> PII; typedef double D; typedef long double LD; typedef vector<PII> VII; #define FOR(i,x,y) for(int i=(x);i<=(y);++i) #define REP(i,x) FOR(i,0,(x)-1) #define FORD(i,x,y) for(int i=(x);i>=(y);--i) #define VAR(i,c) __typeof(c) i=(c) #define FORE(i,c) for(VAR(i,(c).begin());i!=(c).end();++i) #define SIZE(c) (int)((c).size()) #define ALL(c) (c).begin(),(c).end() #define PB push_back #define IN insert #define ER erase #define MP make_pair #define ST first #define ND second #define IOSYNC ios_base::sync_with_stdio(0) struct dupa { int a,b,c,d; }; bool operator< (const dupa &x, const dupa &y) { if(x.a != y.a) return x.a < y.a; if(x.b != y.b) return x.b > y.b; if(x.c != y.c) return x.c < y.c; if(x.d != y.d) return x.d > y.d; } dupa tab[100005]; bool jebaj() { int n; cin >> n; REP(i, n) cin >> tab[i].a >> tab[i].b >> tab[i].c >> tab[i].d; sort(tab, tab + n); FOR(i, 1, n - 1) { if(tab[i].c < tab[0].c || tab[i].d > tab[0].d) return false; } return true; } int main() { IOSYNC; int t; //t = 1; cin >> t; REP(i, t) { if(jebaj()) cout << "TAK\n"; else cout << "NIE\n"; } } |
English