/* * main.cpp * * Created on: 12-05-2014 * Author: adasdeb */ #include <iostream> typedef struct mir { int wl, wu, hl, hu; } mirror; bool einc(mirror ovr, mirror sub); int main(void) { int ds, zak; std::cin.sync_with_stdio(false); std::cin >> ds; while(ds--) { mirror max, maj; bool exists = true; std::cin >> zak; std::cin >> max.wl >> max.wu >> max.hl >> max.hu; maj = max; while(--zak) { mirror tmp; std::cin >> tmp.wl >> tmp.wu >> tmp.hl >> tmp.hu; //Update max range if(tmp.wl < max.wl) max.wl = tmp.wl; if(tmp.wu > max.wu) max.wu = tmp.wu; if(tmp.hl < max.hl) max.hl = tmp.hl; if(tmp.hu > max.hu) max.hu = tmp.hu; // if(einc(tmp, max)) //Check if tmp encloses current max { exists = true; //Then majorant exist if(einc(tmp, maj)) //If tmp also encloses current majorant maj = tmp; //It becomes a new majorant } else if(einc(maj, max)) //If tmp does not encloses max, but current majorant does exists = true; //Then majorant exist else exists = false; //Else majorant does not exist } if(exists) std::cout << "TAK" << "\n"; else std::cout << "NIE" << "\n"; } return 0; } bool einc(mirror ovr, mirror sub) { if( ovr.wl <= sub.wl && ovr.wu >= sub.wu && ovr.hl <= sub.hl && ovr.hu >= sub.hu) return true; return false; }
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 | /* * main.cpp * * Created on: 12-05-2014 * Author: adasdeb */ #include <iostream> typedef struct mir { int wl, wu, hl, hu; } mirror; bool einc(mirror ovr, mirror sub); int main(void) { int ds, zak; std::cin.sync_with_stdio(false); std::cin >> ds; while(ds--) { mirror max, maj; bool exists = true; std::cin >> zak; std::cin >> max.wl >> max.wu >> max.hl >> max.hu; maj = max; while(--zak) { mirror tmp; std::cin >> tmp.wl >> tmp.wu >> tmp.hl >> tmp.hu; //Update max range if(tmp.wl < max.wl) max.wl = tmp.wl; if(tmp.wu > max.wu) max.wu = tmp.wu; if(tmp.hl < max.hl) max.hl = tmp.hl; if(tmp.hu > max.hu) max.hu = tmp.hu; // if(einc(tmp, max)) //Check if tmp encloses current max { exists = true; //Then majorant exist if(einc(tmp, maj)) //If tmp also encloses current majorant maj = tmp; //It becomes a new majorant } else if(einc(maj, max)) //If tmp does not encloses max, but current majorant does exists = true; //Then majorant exist else exists = false; //Else majorant does not exist } if(exists) std::cout << "TAK" << "\n"; else std::cout << "NIE" << "\n"; } return 0; } bool einc(mirror ovr, mirror sub) { if( ovr.wl <= sub.wl && ovr.wu >= sub.wu && ovr.hl <= sub.hl && ovr.hu >= sub.hu) return true; return false; } |