#include <iostream> using namespace std; int main() { int t, n, wa[100001], wb[100001], ha[100001], hb[100001], wmin, wmax, hmin, hmax, a, b, c, d; cin >> t; for (int i = 0; i < t; i++) { cin >> n; for (int j = 0; j < n; j++) { cin >> wa[j] >> wb[j] >> ha[j] >> hb[j]; if (j == 0) { wmin = wa[j]; a = j; wmax = wb[j]; b = j; hmin = ha[j]; c = j; hmax = hb[j]; d = j; } else { if (wa[j] < wmin) { wmin = wa[j]; a = j; } if (wb[j] > wmax) { wmax = wb[j]; b = j; } if (ha[j] < hmin) { hmin = ha[j]; c = j; } if (hb[j] > hmax) { hmax = hb[j]; d = j; } } } if (a == b == c == d) 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 46 47 48 49 50 51 52 53 54 55 | #include <iostream> using namespace std; int main() { int t, n, wa[100001], wb[100001], ha[100001], hb[100001], wmin, wmax, hmin, hmax, a, b, c, d; cin >> t; for (int i = 0; i < t; i++) { cin >> n; for (int j = 0; j < n; j++) { cin >> wa[j] >> wb[j] >> ha[j] >> hb[j]; if (j == 0) { wmin = wa[j]; a = j; wmax = wb[j]; b = j; hmin = ha[j]; c = j; hmax = hb[j]; d = j; } else { if (wa[j] < wmin) { wmin = wa[j]; a = j; } if (wb[j] > wmax) { wmax = wb[j]; b = j; } if (ha[j] < hmin) { hmin = ha[j]; c = j; } if (hb[j] > hmax) { hmax = hb[j]; d = j; } } } if (a == b == c == d) cout << "TAK" << endl; else cout << "NIE" << endl; } return 0; } |