#include <iostream> #include <algorithm> using namespace std; int main() { int T, n; int w1,w2,h1,h2; int wmin, wmax, hmin, hmax; bool maj ; ios_base::sync_with_stdio (false); cin >> T; while(T-->0) { cin >> n; maj = true; cin >> wmin >> wmax >> hmin >> hmax; for(int i=1;i<n;i++) { cin >> w1 >> w2 >> h1 >> h2; if( ( w1 < wmin || w2 > wmax || h1 < hmin || h2 > hmax) ) if( w1 <= wmin && w2 >= wmax && h1 <= hmin && h2 >= hmax) maj = true; else maj = false; if(w1==wmin && w2==wmax && h1==hmin && h2==hmax) maj = true; wmin = min(w1, wmin); wmax = max(w2, wmax); hmin = min(h1, hmin); hmax = max(hmax, h2); } if(maj==true) cout << "TAK\n"; else cout << "NIE\n"; } }
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 | #include <iostream> #include <algorithm> using namespace std; int main() { int T, n; int w1,w2,h1,h2; int wmin, wmax, hmin, hmax; bool maj ; ios_base::sync_with_stdio (false); cin >> T; while(T-->0) { cin >> n; maj = true; cin >> wmin >> wmax >> hmin >> hmax; for(int i=1;i<n;i++) { cin >> w1 >> w2 >> h1 >> h2; if( ( w1 < wmin || w2 > wmax || h1 < hmin || h2 > hmax) ) if( w1 <= wmin && w2 >= wmax && h1 <= hmin && h2 >= hmax) maj = true; else maj = false; if(w1==wmin && w2==wmax && h1==hmin && h2==hmax) maj = true; wmin = min(w1, wmin); wmax = max(w2, wmax); hmin = min(h1, hmin); hmax = max(hmax, h2); } if(maj==true) cout << "TAK\n"; else cout << "NIE\n"; } } |