// Sebastian jaszczur, zadanie LUStro
#include <iostream>
#include <vector>
using namespace std;
class Zaklad
{
public:
int af;
int al;
int bf;
int bl;
Zaklad(int af, int al, int bf, int bl)
{
this->af = af;
this->al = al;
this->bf = bf;
this->bl = bl;
}
bool majoryzuje(Zaklad othr)
{
if(af<=othr.af and al>=othr.al and bf<=othr.bf and bl>=othr.bl)
return true;
else
return false;
}
};
int main()
{
ios_base::sync_with_stdio(0);
int t;
cin>>t;
for(int it=0; it<t; it++)
{
int n;
cin>>n;
vector<Zaklad> vec;
int faworyt = -1;
for(int in=0; in<n; in++)
{
int a, b, c, d;
cin>>a>>b>>c>>d;
vec.push_back(Zaklad(a, b, c, d));
if(faworyt == -1)
faworyt = in;
else
{
if(vec[in].majoryzuje(vec[faworyt]))
faworyt = in;
}
}
bool odpowiedz_tak = true;
for(auto zaklad: vec)
{
if(not vec[faworyt].majoryzuje(zaklad))
{
odpowiedz_tak = false;
break;
}
}
if(odpowiedz_tak)
cout<<"TAK\n";
else
cout<<"NIE\n";
}
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 | // Sebastian jaszczur, zadanie LUStro #include <iostream> #include <vector> using namespace std; class Zaklad { public: int af; int al; int bf; int bl; Zaklad(int af, int al, int bf, int bl) { this->af = af; this->al = al; this->bf = bf; this->bl = bl; } bool majoryzuje(Zaklad othr) { if(af<=othr.af and al>=othr.al and bf<=othr.bf and bl>=othr.bl) return true; else return false; } }; int main() { ios_base::sync_with_stdio(0); int t; cin>>t; for(int it=0; it<t; it++) { int n; cin>>n; vector<Zaklad> vec; int faworyt = -1; for(int in=0; in<n; in++) { int a, b, c, d; cin>>a>>b>>c>>d; vec.push_back(Zaklad(a, b, c, d)); if(faworyt == -1) faworyt = in; else { if(vec[in].majoryzuje(vec[faworyt])) faworyt = in; } } bool odpowiedz_tak = true; for(auto zaklad: vec) { if(not vec[faworyt].majoryzuje(zaklad)) { odpowiedz_tak = false; break; } } if(odpowiedz_tak) cout<<"TAK\n"; else cout<<"NIE\n"; } return 0; } |
English