// Solution to 1LUS // Author: Michal Czuczman <michal.czuczman@gmail.com> // created on Mon May 12 21:59:22 CEST 2014 #include <iostream> using namespace std; typedef unsigned int uint; typedef unsigned long long ull; class Mirror { int w1, w2, h1, h2; public: void extend_max(const Mirror& m) { if(m.w1 < w1) { w1 = m.w1; } if(m.w2 > w2) { w2 = m.w2; } if(m.h1 < h1) { h1 = m.h1; } if(m.h2 > h2) { h2 = m.h2; } } bool covers(const Mirror& m) { return w1 <= m.w1 && w2 >= m.w2 && h1 <= m.h1 && h2 >= m.h2; } friend istream& operator>>(istream& is, Mirror& m); friend ostream& operator<<(ostream& os, const Mirror& m); }; istream& operator>>(istream& is, Mirror& m) { return is >> m.w1 >> m.w2 >> m.h1 >> m.h2; } ostream& operator<<(ostream& os, const Mirror& m) { return os << "{ " << m.w1 << ":" << m.w2 << ", " << m.h1 << ":" << m.h2 << " }"; } void test() { int n; cin >> n; Mirror best; Mirror max; cin >> best; max = best; for(int i = 1; i < n; ++i) { Mirror current; cin >> current; if(current.covers(max)) { best = current; } max.extend_max(current); } if(best.covers(max)) { cout << "TAK\n"; } else { cout << "NIE\n"; } } int main() { ios::sync_with_stdio(false); int z; for (cin >> z; z; --z) test(); }
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 | // Solution to 1LUS // Author: Michal Czuczman <michal.czuczman@gmail.com> // created on Mon May 12 21:59:22 CEST 2014 #include <iostream> using namespace std; typedef unsigned int uint; typedef unsigned long long ull; class Mirror { int w1, w2, h1, h2; public: void extend_max(const Mirror& m) { if(m.w1 < w1) { w1 = m.w1; } if(m.w2 > w2) { w2 = m.w2; } if(m.h1 < h1) { h1 = m.h1; } if(m.h2 > h2) { h2 = m.h2; } } bool covers(const Mirror& m) { return w1 <= m.w1 && w2 >= m.w2 && h1 <= m.h1 && h2 >= m.h2; } friend istream& operator>>(istream& is, Mirror& m); friend ostream& operator<<(ostream& os, const Mirror& m); }; istream& operator>>(istream& is, Mirror& m) { return is >> m.w1 >> m.w2 >> m.h1 >> m.h2; } ostream& operator<<(ostream& os, const Mirror& m) { return os << "{ " << m.w1 << ":" << m.w2 << ", " << m.h1 << ":" << m.h2 << " }"; } void test() { int n; cin >> n; Mirror best; Mirror max; cin >> best; max = best; for(int i = 1; i < n; ++i) { Mirror current; cin >> current; if(current.covers(max)) { best = current; } max.extend_max(current); } if(best.covers(max)) { cout << "TAK\n"; } else { cout << "NIE\n"; } } int main() { ios::sync_with_stdio(false); int z; for (cin >> z; z; --z) test(); } |