#include <iostream> #include <map> #include <set> #include <algorithm> #include<iostream> #include<cstdio> #define DEBUG_MS 0 using namespace std; int main() { int t,n; int w1,w2,h1,h2; int ml_w1, ml_w2,ml_h1,ml_h2; ios_base::sync_with_stdio(0); //cin.sync_with_stdio(false); //cin >> t; //max 10 scanf("%d", &t); for(int i=0;i<t;i++) { int min_w1=1000000000,min_h1=1000000000, max_w2=-1, max_h2=-1; ml_w1 = min_w1; ml_w2 = max_w2; ml_h1 = min_h1; ml_h2 = max_h2; // cin >>n; // n=2 .. 100 000 scanf("%d", &n); bool update; for (int j=0;j<n;j++) { //cin >> w1;cin >> w2;cin >> h1; cin >> h2; scanf("%d%d%d%d", &w1, &w2, &h1, &h2); // cout << w1 << ", " << w2 << ", " << h1 << ", " << h2 << endl; update = false; if (w1<=min_w1) { min_w1=w1; update = true; } if (h1<=min_h1) { min_h1=h1; update = true; } if (w2>=max_w2) { max_w2=w2; update = true; } if (h2>=max_h2) { max_h2=h2; update = true; } if (update) { if (w1<=ml_w1 && w2>=ml_w2 && h1<=ml_h1 && h2>=ml_h2) { ml_w1 = w1; ml_w2 = w2; ml_h1 = h1; ml_h2 = h2; } } } if (ml_w1==min_w1 && ml_w2==max_w2 && ml_h1==min_h1 && ml_h2==max_h2) cout << "TAK" << std::endl; else cout << "NIE" << std::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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include <iostream> #include <map> #include <set> #include <algorithm> #include<iostream> #include<cstdio> #define DEBUG_MS 0 using namespace std; int main() { int t,n; int w1,w2,h1,h2; int ml_w1, ml_w2,ml_h1,ml_h2; ios_base::sync_with_stdio(0); //cin.sync_with_stdio(false); //cin >> t; //max 10 scanf("%d", &t); for(int i=0;i<t;i++) { int min_w1=1000000000,min_h1=1000000000, max_w2=-1, max_h2=-1; ml_w1 = min_w1; ml_w2 = max_w2; ml_h1 = min_h1; ml_h2 = max_h2; // cin >>n; // n=2 .. 100 000 scanf("%d", &n); bool update; for (int j=0;j<n;j++) { //cin >> w1;cin >> w2;cin >> h1; cin >> h2; scanf("%d%d%d%d", &w1, &w2, &h1, &h2); // cout << w1 << ", " << w2 << ", " << h1 << ", " << h2 << endl; update = false; if (w1<=min_w1) { min_w1=w1; update = true; } if (h1<=min_h1) { min_h1=h1; update = true; } if (w2>=max_w2) { max_w2=w2; update = true; } if (h2>=max_h2) { max_h2=h2; update = true; } if (update) { if (w1<=ml_w1 && w2>=ml_w2 && h1<=ml_h1 && h2>=ml_h2) { ml_w1 = w1; ml_w2 = w2; ml_h1 = h1; ml_h2 = h2; } } } if (ml_w1==min_w1 && ml_w2==max_w2 && ml_h1==min_h1 && ml_h2==max_h2) cout << "TAK" << std::endl; else cout << "NIE" << std::endl; } return 0; } |