#include <iostream> #define max(a,b) (((a)>(b))?(a):(b)) #define min(a,b) (((a)<(b))?(a):(b)) using namespace std; int main() { cin.sync_with_stdio(false); int t, n, w1, w2, h1, h2; cin >> t; while (t--) { cin >> n; // Sewt the first one as a majoring one. n--; cin >> w1 >> w2 >> h1 >> h2; int maj_w1 = w1, maj_w2 = w2, maj_h1 = h1, maj_h2 = h2; bool maj = true; while (n--) { cin >> w1 >> w2 >> h1 >> h2; // Check if your old major is up to date. if (w1 < maj_w1 || w2 > maj_w2 || h1 < maj_h1 || h2 > maj_h2) { maj = false; maj_w1 = min(w1, maj_w1); maj_w2 = max(w2, maj_w2); maj_h1 = min(h1, maj_h1); maj_h2 = max(h2, maj_h2); } if (!maj && w1 == maj_w1 && w2 == maj_w2 && h1 == maj_h1 && h2 == maj_h2) { maj = true; } } if (maj) cout << "TAK\n"; else cout << "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 49 | #include <iostream> #define max(a,b) (((a)>(b))?(a):(b)) #define min(a,b) (((a)<(b))?(a):(b)) using namespace std; int main() { cin.sync_with_stdio(false); int t, n, w1, w2, h1, h2; cin >> t; while (t--) { cin >> n; // Sewt the first one as a majoring one. n--; cin >> w1 >> w2 >> h1 >> h2; int maj_w1 = w1, maj_w2 = w2, maj_h1 = h1, maj_h2 = h2; bool maj = true; while (n--) { cin >> w1 >> w2 >> h1 >> h2; // Check if your old major is up to date. if (w1 < maj_w1 || w2 > maj_w2 || h1 < maj_h1 || h2 > maj_h2) { maj = false; maj_w1 = min(w1, maj_w1); maj_w2 = max(w2, maj_w2); maj_h1 = min(h1, maj_h1); maj_h2 = max(h2, maj_h2); } if (!maj && w1 == maj_w1 && w2 == maj_w2 && h1 == maj_h1 && h2 == maj_h2) { maj = true; } } if (maj) cout << "TAK\n"; else cout << "NIE\n"; } return 0; } |