#include <iostream> #define MAX 1000000001 using namespace std; int main() { int t; int n; int w1,w2,h1,h2; int ok; int w_min, w_max, h_min, h_max; cin.sync_with_stdio(false); cin >> t; for(int i=0; i<t; ++i) { cin >> n; ok = 0; w_max = h_max = 0; w_min = h_min = MAX; for(int j=0; j<n; ++j) { cin >> w1 >> w2 >> h1 >> h2; if (w1<w_min) { w_min = w1; ok = 0; } if (w2>w_max) { w_max = w2; ok = 0; } if (h1<h_min) { h_min = h1; ok = 0; } if (h2>h_max) { h_max = h2; ok = 0; } if (w1==w_min && w2==w_max && h1==h_min && h2==h_max) { ok = 1; } } if (ok) { 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #include <iostream> #define MAX 1000000001 using namespace std; int main() { int t; int n; int w1,w2,h1,h2; int ok; int w_min, w_max, h_min, h_max; cin.sync_with_stdio(false); cin >> t; for(int i=0; i<t; ++i) { cin >> n; ok = 0; w_max = h_max = 0; w_min = h_min = MAX; for(int j=0; j<n; ++j) { cin >> w1 >> w2 >> h1 >> h2; if (w1<w_min) { w_min = w1; ok = 0; } if (w2>w_max) { w_max = w2; ok = 0; } if (h1<h_min) { h_min = h1; ok = 0; } if (h2>h_max) { h_max = h2; ok = 0; } if (w1==w_min && w2==w_max && h1==h_min && h2==h_max) { ok = 1; } } if (ok) { cout << "TAK\n"; } else { cout << "NIE\n"; } } return 0; } |