#include <iostream> #include <algorithm> using namespace std; int main () { int z; cin >> z; while (z--) { int n; cin >> n; int best_w1 = 2000000000; int best_w2 = -1; int best_h1 = 2000000000; int best_h2 = -1; int need_better = 1; for (int i = 0; i < n; i++) { int w1, w2, h1, h2; cin >> w1 >> w2 >> h1 >> h2; if (w1 <= best_w1 && w2 >= best_w2 && h1 <= best_h1 && h2 >= best_h2) need_better = 0; else if (w1 < best_w1 || w2 > best_w2 || h1 < best_h1 || h2 > best_h2) need_better = 1; best_w1 = min (best_w1, w1); best_w2 = max (best_w2, w2); best_h1 = min (best_h1, h1); best_h2 = max (best_h2, h2); } cout << (need_better ? "NIE" : "TAK") << 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 | #include <iostream> #include <algorithm> using namespace std; int main () { int z; cin >> z; while (z--) { int n; cin >> n; int best_w1 = 2000000000; int best_w2 = -1; int best_h1 = 2000000000; int best_h2 = -1; int need_better = 1; for (int i = 0; i < n; i++) { int w1, w2, h1, h2; cin >> w1 >> w2 >> h1 >> h2; if (w1 <= best_w1 && w2 >= best_w2 && h1 <= best_h1 && h2 >= best_h2) need_better = 0; else if (w1 < best_w1 || w2 > best_w2 || h1 < best_h1 || h2 > best_h2) need_better = 1; best_w1 = min (best_w1, w1); best_w2 = max (best_w2, w2); best_h1 = min (best_h1, h1); best_h2 = max (best_h2, h2); } cout << (need_better ? "NIE" : "TAK") << endl; } return 0; } |