#include <stdio.h> #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int t, n, w1, w2, h1, h2; int sw1, sw2, sh1, sh2; int nw1, nw2, nh1, nh2; cin >> t; for (int i=0; i<t; i++){ cin >> n; for (int j=0; j<n; j++){ cin >> w1 >> w2 >> h1 >> h2; if (j==0){ sw1 = nw1 = w1; sw2 = nw2 = w2; sh1 = nh1 = h1; sh2 = nh2 = h2; } else{ if (w1 < sw1) sw1 = w1; if (w2 > sw2) sw2 = w2; if (h1 < sh1) sh1 = h1; if (h2 > sh2) sh2 = h2; if (w2-w1 > nw2-nw1 && h2-h1 > nh2 - nh1){ nw1 = w1; nw2 = w2; nh1 = h1; nh2 = h2; } } } cout << ((nw1<=sw1 && nw2>=sw2 && nh1<=sh1 && nh2>=sh2) ? "TAK" : "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 | #include <stdio.h> #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int t, n, w1, w2, h1, h2; int sw1, sw2, sh1, sh2; int nw1, nw2, nh1, nh2; cin >> t; for (int i=0; i<t; i++){ cin >> n; for (int j=0; j<n; j++){ cin >> w1 >> w2 >> h1 >> h2; if (j==0){ sw1 = nw1 = w1; sw2 = nw2 = w2; sh1 = nh1 = h1; sh2 = nh2 = h2; } else{ if (w1 < sw1) sw1 = w1; if (w2 > sw2) sw2 = w2; if (h1 < sh1) sh1 = h1; if (h2 > sh2) sh2 = h2; if (w2-w1 > nw2-nw1 && h2-h1 > nh2 - nh1){ nw1 = w1; nw2 = w2; nh1 = h1; nh2 = h2; } } } cout << ((nw1<=sw1 && nw2>=sw2 && nh1<=sh1 && nh2>=sh2) ? "TAK" : "NIE") << endl; } return 0; } |