#include <iostream> using namespace std; struct Producer { int w1,w2; int h1,h2; void read() { cin >> w1; cin >> w2; cin >> h1; cin >> h2; } }; struct ProducerMax : public Producer { bool isMax; ProducerMax(Producer& curr) { w1=curr.w1; w2=curr.w2; h1=curr.h1; h2=curr.h2; isMax=true; } void update(Producer& curr) { bool changed=false; if(curr.w1<w1) { w1=curr.w1; changed=true; } if(curr.h1<h1) { h1=curr.h1; changed=true; } if(curr.w2>w2) { w2=curr.w2; changed=true; } if(curr.h2>h2) { h2=curr.h2; changed=true; } if (changed) { if( curr.w1 == w1 && curr.w2 == w2 && curr.h1 == h1 && curr.h2 == h2) { isMax=true; } else { isMax=false; } } } }; int main() { ios_base::sync_with_stdio(false); int testCases = 0; int n; cin >> testCases; for(int testCase=0; testCase < testCases; ++testCase) { Producer curr; cin >> n; curr.read(); ProducerMax best(curr); for(int i=1; i<n; ++i) { curr.read(); best.update(curr); } if (best.isMax==true) { 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #include <iostream> using namespace std; struct Producer { int w1,w2; int h1,h2; void read() { cin >> w1; cin >> w2; cin >> h1; cin >> h2; } }; struct ProducerMax : public Producer { bool isMax; ProducerMax(Producer& curr) { w1=curr.w1; w2=curr.w2; h1=curr.h1; h2=curr.h2; isMax=true; } void update(Producer& curr) { bool changed=false; if(curr.w1<w1) { w1=curr.w1; changed=true; } if(curr.h1<h1) { h1=curr.h1; changed=true; } if(curr.w2>w2) { w2=curr.w2; changed=true; } if(curr.h2>h2) { h2=curr.h2; changed=true; } if (changed) { if( curr.w1 == w1 && curr.w2 == w2 && curr.h1 == h1 && curr.h2 == h2) { isMax=true; } else { isMax=false; } } } }; int main() { ios_base::sync_with_stdio(false); int testCases = 0; int n; cin >> testCases; for(int testCase=0; testCase < testCases; ++testCase) { Producer curr; cin >> n; curr.read(); ProducerMax best(curr); for(int i=1; i<n; ++i) { curr.read(); best.update(curr); } if (best.isMax==true) { cout << "TAK\n"; } else { cout << "NIE\n"; } } return 0; } |