#include <iostream> #include <climits> using namespace std; int main() { long t, n, w1, w2, h1, h2, cur_w1, cur_w2, cur_h1, cur_h2, min_w1, max_w2, min_h1, max_h2; long i=0; cin.sync_with_stdio(false); cin>>t; while(t--) { min_w1 = min_h1 = LONG_MAX; max_w2 = max_h2 = LONG_MIN; cin>>n; cin>>cur_w1>>cur_w2>>cur_h1>>cur_h2; for(i=1; i<n; ++i) { cin>>w1>>w2>>h1>>h2; if(w1<=cur_w1 && w2>=cur_w2 && h1<=cur_h1 && h2>=cur_h2) { cur_w1 = w1; cur_w2 = w2; cur_h1 = h1; cur_h2 = h2; } if(w1< min_w1) min_w1 = w1; if(w2 > max_w2) max_w2 = w2; if(h1< min_h1) min_h1 = h1; if(h2 > max_h2) max_h2 = h2; } if(min_w1<cur_w1 || max_w2>cur_w2 || min_h1<cur_h1 || max_h2>cur_h2) cout<<"NIE"<<endl; else cout<<"TAK"<<endl; } 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 | #include <iostream> #include <climits> using namespace std; int main() { long t, n, w1, w2, h1, h2, cur_w1, cur_w2, cur_h1, cur_h2, min_w1, max_w2, min_h1, max_h2; long i=0; cin.sync_with_stdio(false); cin>>t; while(t--) { min_w1 = min_h1 = LONG_MAX; max_w2 = max_h2 = LONG_MIN; cin>>n; cin>>cur_w1>>cur_w2>>cur_h1>>cur_h2; for(i=1; i<n; ++i) { cin>>w1>>w2>>h1>>h2; if(w1<=cur_w1 && w2>=cur_w2 && h1<=cur_h1 && h2>=cur_h2) { cur_w1 = w1; cur_w2 = w2; cur_h1 = h1; cur_h2 = h2; } if(w1< min_w1) min_w1 = w1; if(w2 > max_w2) max_w2 = w2; if(h1< min_h1) min_h1 = h1; if(h2 > max_h2) max_h2 = h2; } if(min_w1<cur_w1 || max_w2>cur_w2 || min_h1<cur_h1 || max_h2>cur_h2) cout<<"NIE"<<endl; else cout<<"TAK"<<endl; } return 0; } |