#include <iostream> #include <vector> using namespace std; vector< int >width; vector< int >height; struct firma{ int w_min; int w_max; int h_min; int h_max; }; void clear(){ width.clear(); height.clear(); } int main(){ std::ios_base::sync_with_stdio(0); int t; cin >> t; while(t--){ int n; cin >> n; firma tab[n]; for(int i = 0; i < n; i++){ cin >> tab[i].w_min >> tab[i].w_max >> tab[i].h_min >> tab[i].h_max; width.push_back(tab[i].w_min); width.push_back(tab[i].w_max); height.push_back(tab[i].h_min); height.push_back(tab[i].h_max); } int w = 0; int h = 0; int q = 0; // szerokosc int r = 0; int x = 0; // wysokosc int y = 0; bool result = false; for(int i = 0; i < n; i++){ q = tab[i].w_min; r = tab[i].w_max; x = tab[i].h_min; y = tab[i].h_max; for(int j = 0; j < 2 * n; j++){ if(width[j] >= q && width[j] <= r) w ++; if(height[j] >= x && height[j] <= y) h ++; } if(w == 2 * n && h == 2 * n){ result = true; break; } else{ w = 0; h = 0; } } clear(); if(result == true) cout << "TAK" << endl; else cout << "NIE" << 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 | #include <iostream> #include <vector> using namespace std; vector< int >width; vector< int >height; struct firma{ int w_min; int w_max; int h_min; int h_max; }; void clear(){ width.clear(); height.clear(); } int main(){ std::ios_base::sync_with_stdio(0); int t; cin >> t; while(t--){ int n; cin >> n; firma tab[n]; for(int i = 0; i < n; i++){ cin >> tab[i].w_min >> tab[i].w_max >> tab[i].h_min >> tab[i].h_max; width.push_back(tab[i].w_min); width.push_back(tab[i].w_max); height.push_back(tab[i].h_min); height.push_back(tab[i].h_max); } int w = 0; int h = 0; int q = 0; // szerokosc int r = 0; int x = 0; // wysokosc int y = 0; bool result = false; for(int i = 0; i < n; i++){ q = tab[i].w_min; r = tab[i].w_max; x = tab[i].h_min; y = tab[i].h_max; for(int j = 0; j < 2 * n; j++){ if(width[j] >= q && width[j] <= r) w ++; if(height[j] >= x && height[j] <= y) h ++; } if(w == 2 * n && h == 2 * n){ result = true; break; } else{ w = 0; h = 0; } } clear(); if(result == true) cout << "TAK" << endl; else cout << "NIE" << endl; } return 0; } |