#include <iostream> using namespace std; struct Oferta { int min_sz; int max_sz; int min_dl; int max_dl; Oferta(); Oferta( int min_sz, int max_sz, int min_dl, int max_dl ); }; istream& operator>> ( istream&, Oferta&); ostream& operator<< ( ostream&, Oferta const&); bool operator== ( Oferta const& a, Oferta const& b); Oferta best( Oferta const& a, Oferta const& b); int main() { ios_base::sync_with_stdio( false ); int ile_zadan = 0; cin >> ile_zadan; for( int i = 0; i < ile_zadan; ++i ) { int ile_zakladow = 0; cin >> ile_zakladow; Oferta major; cin >> major; Oferta rekordy( major ); //cerr << major << endl; //cerr << rekordy << endl; for( int j = 1; j < ile_zakladow; ++j ) { Oferta o; cin >> o; rekordy = best(rekordy, o); //cerr << rekordy << endl; if( o == rekordy ) { major = o; } } cout << ((major == rekordy)? "TAK" : "NIE" ) << "\n"; } } Oferta best(Oferta const& a, Oferta const& b) { return Oferta( min(a.min_sz, b.min_sz), max(a.max_sz, b.max_sz), min(a.min_dl, b.min_dl), max(a.max_dl, b.max_dl) ); }; bool operator== ( Oferta const& a, Oferta const& b) { return ( (a.min_sz == b.min_sz) && (a.max_sz == b.max_sz) && (a.min_dl == b.min_dl) && (a.max_dl == b.max_dl) ); } istream& operator>> ( istream& is, Oferta& o ) { is >> o.min_sz >> o.max_sz >> o.min_dl >> o.max_dl; return is; } ostream& operator<< ( ostream& os, Oferta const& o) { os << "[" << o.min_sz << "," << o.max_sz << "," << o.min_sz << "," << o.max_sz << "]"; return os; } Oferta::Oferta() : min_sz(0), max_sz(0), min_dl(0), max_dl(0) {}; Oferta::Oferta( int min_sz, int max_sz, int min_dl, int max_dl) : min_sz(min_sz), max_sz(max_sz), min_dl(min_dl), max_dl(max_dl) {};
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 88 89 90 91 92 93 94 95 96 97 98 | #include <iostream> using namespace std; struct Oferta { int min_sz; int max_sz; int min_dl; int max_dl; Oferta(); Oferta( int min_sz, int max_sz, int min_dl, int max_dl ); }; istream& operator>> ( istream&, Oferta&); ostream& operator<< ( ostream&, Oferta const&); bool operator== ( Oferta const& a, Oferta const& b); Oferta best( Oferta const& a, Oferta const& b); int main() { ios_base::sync_with_stdio( false ); int ile_zadan = 0; cin >> ile_zadan; for( int i = 0; i < ile_zadan; ++i ) { int ile_zakladow = 0; cin >> ile_zakladow; Oferta major; cin >> major; Oferta rekordy( major ); //cerr << major << endl; //cerr << rekordy << endl; for( int j = 1; j < ile_zakladow; ++j ) { Oferta o; cin >> o; rekordy = best(rekordy, o); //cerr << rekordy << endl; if( o == rekordy ) { major = o; } } cout << ((major == rekordy)? "TAK" : "NIE" ) << "\n"; } } Oferta best(Oferta const& a, Oferta const& b) { return Oferta( min(a.min_sz, b.min_sz), max(a.max_sz, b.max_sz), min(a.min_dl, b.min_dl), max(a.max_dl, b.max_dl) ); }; bool operator== ( Oferta const& a, Oferta const& b) { return ( (a.min_sz == b.min_sz) && (a.max_sz == b.max_sz) && (a.min_dl == b.min_dl) && (a.max_dl == b.max_dl) ); } istream& operator>> ( istream& is, Oferta& o ) { is >> o.min_sz >> o.max_sz >> o.min_dl >> o.max_dl; return is; } ostream& operator<< ( ostream& os, Oferta const& o) { os << "[" << o.min_sz << "," << o.max_sz << "," << o.min_sz << "," << o.max_sz << "]"; return os; } Oferta::Oferta() : min_sz(0), max_sz(0), min_dl(0), max_dl(0) {}; Oferta::Oferta( int min_sz, int max_sz, int min_dl, int max_dl) : min_sz(min_sz), max_sz(max_sz), min_dl(min_dl), max_dl(max_dl) {}; |