#include <iostream> int main() { int t, n, c, i, w_min, w_max, h_min, h_max, w1, w2, h1, h2; bool r; scanf("%d", &t); for ( c = 0 ; c < t ; c++) { w_min = 1000000000; w_max = 1; h_min = 1000000000; h_max = 1; scanf("%d", &n); r = false; for ( i = 0 ; i < n ; i++) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if(w1<=w_min & w2>=w_max & h1 <=h_min & h2 >= h_max) { r = true; w_min = w1; w_max = w2; h_min = h1; h_max = h2; } else if(w1<w_min | w2>w_max | h1 <h_min | h2 > h_max) { r = false; w_min = std::min(w_min, w1); w_max = std::max(w_max, w2); h_min = std::min(h_min, h1); h_max = std::max(h_max, h2); } } if(r) 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 42 43 44 45 46 47 48 | #include <iostream> int main() { int t, n, c, i, w_min, w_max, h_min, h_max, w1, w2, h1, h2; bool r; scanf("%d", &t); for ( c = 0 ; c < t ; c++) { w_min = 1000000000; w_max = 1; h_min = 1000000000; h_max = 1; scanf("%d", &n); r = false; for ( i = 0 ; i < n ; i++) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); if(w1<=w_min & w2>=w_max & h1 <=h_min & h2 >= h_max) { r = true; w_min = w1; w_max = w2; h_min = h1; h_max = h2; } else if(w1<w_min | w2>w_max | h1 <h_min | h2 > h_max) { r = false; w_min = std::min(w_min, w1); w_max = std::max(w_max, w2); h_min = std::min(h_min, h1); h_max = std::max(h_max, h2); } } if(r) printf("TAK\n"); else printf("NIE\n"); } return 0; } |