#include <iostream> #include <algorithm> using namespace std; const int MAXN = 1e5; int w1[MAXN], w2[MAXN], h1[MAXN], h2[MAXN]; int main() { ios_base::sync_with_stdio(false); int t, n; int w_min, w_max, h_min, h_max; //int w1, w2, h1, h2; cin >> t; for(int i = 0; i< t; ++ i) { w_min = 1e9, w_max = 0, h_min = 1e9, h_max = 0; cin >> n; for (int j = 0; j< n; ++j) { cin >> w1[j] >> w2[j] >> h1[j] >> h2[j]; w_min = min(w_min, w1[j]); w_max = max(w_max, w2[j]); h_min = min(h_min, h1[j]); h_max = max(h_max, h2[j]); } //cout << w_min << w_max << h_min << h_max << endl; bool result = false; for (int j = 0 ; j < n; ++j) { if(w1[j] == w_min and w2[j] == w_max and h1[j] == h_min and h2[j] == h_max) { result = true; break; } } if(result) cout<<"TAK"<<endl; else cout<<"NIE"<<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 | #include <iostream> #include <algorithm> using namespace std; const int MAXN = 1e5; int w1[MAXN], w2[MAXN], h1[MAXN], h2[MAXN]; int main() { ios_base::sync_with_stdio(false); int t, n; int w_min, w_max, h_min, h_max; //int w1, w2, h1, h2; cin >> t; for(int i = 0; i< t; ++ i) { w_min = 1e9, w_max = 0, h_min = 1e9, h_max = 0; cin >> n; for (int j = 0; j< n; ++j) { cin >> w1[j] >> w2[j] >> h1[j] >> h2[j]; w_min = min(w_min, w1[j]); w_max = max(w_max, w2[j]); h_min = min(h_min, h1[j]); h_max = max(h_max, h2[j]); } //cout << w_min << w_max << h_min << h_max << endl; bool result = false; for (int j = 0 ; j < n; ++j) { if(w1[j] == w_min and w2[j] == w_max and h1[j] == h_min and h2[j] == h_max) { result = true; break; } } if(result) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } return 0; } |