#include <cstdio> #include <vector> using namespace std; int n, t, w1, w2, h1, h2, h_min, h_max, w_min, w_max; bool res; vector<int> W1, W2, H1, H2; int main() { scanf("%d", &t); while(t--) { res = false; W1.clear(); W2.clear(); H1.clear(); H2.clear(); h_min = w_min = 1e9; h_max = w_max = 0; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); W1.push_back(w1); W2.push_back(w2); H1.push_back(h1); H2.push_back(h2); w_min = min(w_min, w1); w_max = max(w_max, w2); h_min = min(h_min, h1); h_max = max(h_max, h2); } for(int i = 0; (i<n)&&(res==false); i++) { if(H1[i]==h_min && H2[i]==h_max && W1[i]==w_min && W2[i]==w_max) res = true; } if(res==true) printf("TAK\n"); else printf("NIE\n"); } 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 | #include <cstdio> #include <vector> using namespace std; int n, t, w1, w2, h1, h2, h_min, h_max, w_min, w_max; bool res; vector<int> W1, W2, H1, H2; int main() { scanf("%d", &t); while(t--) { res = false; W1.clear(); W2.clear(); H1.clear(); H2.clear(); h_min = w_min = 1e9; h_max = w_max = 0; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d%d%d%d", &w1, &w2, &h1, &h2); W1.push_back(w1); W2.push_back(w2); H1.push_back(h1); H2.push_back(h2); w_min = min(w_min, w1); w_max = max(w_max, w2); h_min = min(h_min, h1); h_max = max(h_max, h2); } for(int i = 0; (i<n)&&(res==false); i++) { if(H1[i]==h_min && H2[i]==h_max && W1[i]==w_min && W2[i]==w_max) res = true; } if(res==true) printf("TAK\n"); else printf("NIE\n"); } return 0; } |