#include <iostream> using namespace std; main() { int t, n, mins, maxs, minw, maxw, mins1, maxs1, minw1, maxw1 ; cin.sync_with_stdio(false); cin >> t; // liczba testow bool tak;// wyniki for(int i = 0; i < t; i++) { tak = true; cin >> n; // liczba ofert cin >> mins >> maxs >> minw >> maxw; for(int j = 1; j < n; j++) { cin >> mins1 >> maxs1 >> minw1 >> maxw1; if ( mins >= mins1 && maxs <= maxs1 && minw >= minw1 && maxw <= maxw1 ) { mins = mins1; maxs = maxs1; minw = minw1; maxw = maxw1; tak = true; } if(mins > mins1) { mins = mins1; tak = false; } if (maxs < maxs1) { maxs = maxs1; tak = false; } if (minw > minw1) { minw = minw1; tak = false; } if (maxw < maxw1) { maxw = maxw1; tak = false; } } if(tak) { cout << "TAK" << endl; }else{ cout << "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 | #include <iostream> using namespace std; main() { int t, n, mins, maxs, minw, maxw, mins1, maxs1, minw1, maxw1 ; cin.sync_with_stdio(false); cin >> t; // liczba testow bool tak;// wyniki for(int i = 0; i < t; i++) { tak = true; cin >> n; // liczba ofert cin >> mins >> maxs >> minw >> maxw; for(int j = 1; j < n; j++) { cin >> mins1 >> maxs1 >> minw1 >> maxw1; if ( mins >= mins1 && maxs <= maxs1 && minw >= minw1 && maxw <= maxw1 ) { mins = mins1; maxs = maxs1; minw = minw1; maxw = maxw1; tak = true; } if(mins > mins1) { mins = mins1; tak = false; } if (maxs < maxs1) { maxs = maxs1; tak = false; } if (minw > minw1) { minw = minw1; tak = false; } if (maxw < maxw1) { maxw = maxw1; tak = false; } } if(tak) { cout << "TAK" << endl; }else{ cout << "NIE" << endl; } } } |