#include <iostream> #include <vector> using namespace std; class Firma{ public: int wmin; int wmax; int hmin; int hmax; /*Firma(int w1,int w2, int h1, int h2){ wmin = w1; wmax = w2; hmin = h1; hmax = h2; }*/ }; int main(){ int t; cin >> t; for(int i=0 ; i<t; i++){ int n; cin >> n; vector <Firma> v(n); for(int j=0 ; j<n ; j++){ cin >> v[j].wmin >> v[j].wmax >> v[j].hmin >> v[j].hmax; } int wmin = v[0].wmin , wmax = v[0].wmax , hmin = v[0].hmin , hmax = v[0].hmax; bool major = true; for(int j=1 ; j<n ; j++){ if(v[j].wmin > wmin && v[j].wmax < wmax && v[j].hmin > hmin && v[j].hmax < hmax) continue; if(v[j].wmin < wmin){ major = false; wmin = v[j].wmin; } if(v[j].wmax > wmax){ major = false; wmax = v[j].wmax; } if(v[j].hmin < hmin){ major = false; hmin = v[j].hmin; } if(v[j].hmax > hmax){ major = false; hmax = v[j].hmax; } if(v[j].wmin == wmin && v[j].wmax == wmax && v[j].hmin == hmin && v[j].hmax == hmax) major = true; } if(major == true) cout << "TAK" << endl; else cout << "NIE" << endl; } }
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 | #include <iostream> #include <vector> using namespace std; class Firma{ public: int wmin; int wmax; int hmin; int hmax; /*Firma(int w1,int w2, int h1, int h2){ wmin = w1; wmax = w2; hmin = h1; hmax = h2; }*/ }; int main(){ int t; cin >> t; for(int i=0 ; i<t; i++){ int n; cin >> n; vector <Firma> v(n); for(int j=0 ; j<n ; j++){ cin >> v[j].wmin >> v[j].wmax >> v[j].hmin >> v[j].hmax; } int wmin = v[0].wmin , wmax = v[0].wmax , hmin = v[0].hmin , hmax = v[0].hmax; bool major = true; for(int j=1 ; j<n ; j++){ if(v[j].wmin > wmin && v[j].wmax < wmax && v[j].hmin > hmin && v[j].hmax < hmax) continue; if(v[j].wmin < wmin){ major = false; wmin = v[j].wmin; } if(v[j].wmax > wmax){ major = false; wmax = v[j].wmax; } if(v[j].hmin < hmin){ major = false; hmin = v[j].hmin; } if(v[j].hmax > hmax){ major = false; hmax = v[j].hmax; } if(v[j].wmin == wmin && v[j].wmax == wmax && v[j].hmin == hmin && v[j].hmax == hmax) major = true; } if(major == true) cout << "TAK" << endl; else cout << "NIE" << endl; } } |