#include <iostream> #include <algorithm> #include <vector> #include <string> #include <map> #include <set> #include <queue> #include <stack> #include <cmath> #include <cassert> #include <cstring> #include <ext/numeric> using namespace std ; using namespace __gnu_cxx ; typedef long long LL ; typedef pair<int,int> PII ; typedef vector<int> VI ; const int INF = 1000*1000*1000+1000 ; const LL INFLL = (LL)INF * (LL)INF ; #define REP(i,n) for(i=0;i<(n);++i) #define ALL(c) c.begin(),c.end() #define VAR(v,i) __typeof(i) v=(i) #define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i) #define CLEAR(t) memset(t,0,sizeof(t)) #define PB push_back #define MP make_pair #define FI first #define SE second template<class T1, class T2> ostream & operator<<(ostream &s, pair<T1,T2> x) { s << "(" << x.FI << "," << x.SE << ")" ; return s ; } template<class T> ostream & operator<<(ostream &s, const vector<T> &t) { FOREACH(it, t) s << *it << " " ; return s ; } template<class T1, class T2> ostream & operator<<(ostream &s, const map<T1, T2> &t) { FOREACH(it, t) s << *it << " " ; return s ; } const int MAXN = 100100 ; struct desc { int h1, h2, w1, w2 ; } t[MAXN] ; int main() { ios_base::sync_with_stdio(0) ; int C, n, i ; cin >> C ; while(C--) { cin >> n ; int h_min = INF, h_max = -INF, w_min = INF, w_max = -INF ; REP(i,n) { cin >> t[i].h1 >> t[i].h2 >> t[i].w1 >> t[i].w2 ; h_min = min(h_min, t[i].h1) ; h_max = max(h_max, t[i].h2) ; w_min = min(w_min, t[i].w1) ; w_max = max(w_max, t[i].w2) ; } bool ok=false ; REP(i,n) if(t[i].h1==h_min && t[i].h2==h_max && t[i].w1==w_min && t[i].w2==w_max) ok = true ; cout << (ok ? "TAK" : "NIE") << endl ; } }
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 | #include <iostream> #include <algorithm> #include <vector> #include <string> #include <map> #include <set> #include <queue> #include <stack> #include <cmath> #include <cassert> #include <cstring> #include <ext/numeric> using namespace std ; using namespace __gnu_cxx ; typedef long long LL ; typedef pair<int,int> PII ; typedef vector<int> VI ; const int INF = 1000*1000*1000+1000 ; const LL INFLL = (LL)INF * (LL)INF ; #define REP(i,n) for(i=0;i<(n);++i) #define ALL(c) c.begin(),c.end() #define VAR(v,i) __typeof(i) v=(i) #define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i) #define CLEAR(t) memset(t,0,sizeof(t)) #define PB push_back #define MP make_pair #define FI first #define SE second template<class T1, class T2> ostream & operator<<(ostream &s, pair<T1,T2> x) { s << "(" << x.FI << "," << x.SE << ")" ; return s ; } template<class T> ostream & operator<<(ostream &s, const vector<T> &t) { FOREACH(it, t) s << *it << " " ; return s ; } template<class T1, class T2> ostream & operator<<(ostream &s, const map<T1, T2> &t) { FOREACH(it, t) s << *it << " " ; return s ; } const int MAXN = 100100 ; struct desc { int h1, h2, w1, w2 ; } t[MAXN] ; int main() { ios_base::sync_with_stdio(0) ; int C, n, i ; cin >> C ; while(C--) { cin >> n ; int h_min = INF, h_max = -INF, w_min = INF, w_max = -INF ; REP(i,n) { cin >> t[i].h1 >> t[i].h2 >> t[i].w1 >> t[i].w2 ; h_min = min(h_min, t[i].h1) ; h_max = max(h_max, t[i].h2) ; w_min = min(w_min, t[i].w1) ; w_max = max(w_max, t[i].w2) ; } bool ok=false ; REP(i,n) if(t[i].h1==h_min && t[i].h2==h_max && t[i].w1==w_min && t[i].w2==w_max) ok = true ; cout << (ok ? "TAK" : "NIE") << endl ; } } |