#include using namespace std; struct Rect{ int64_t x0,y0,x1,y1; }; int main(){ int n; cin>>n; vector r(n); for (auto &i: r){ cin>>i.x0>>i.y0>>i.x1>>i.y1; assert(i.x1>0 and i.y1>0); i.x1+=i.x0; i.y1+=i.y0; } // Check area of overall bounding box matches combined area of bricks. Rect overall=r[0]; int64_t area=0; for (auto const &i: r){ overall.x0=min(overall.x0,i.x0); overall.x1=max(overall.x1,i.x1); overall.y0=min(overall.y0,i.y0); overall.y1=max(overall.y1,i.y1); area+=(i.x1-i.x0)*(i.y1-i.y0); } if ((overall.x1-overall.x0)*(overall.y1-overall.y0)!=area){ cout<<"no"<> todo_open,todo_close; for (auto const &i: r){ todo_open.emplace_back(i.x0,&i); todo_close.emplace_back(i.x1,&i); } sort(todo_open.begin(),todo_open.end()); sort(todo_close.begin(),todo_close.end()); set> active; for (int i=0,j=0; iy0, todo_close[j].second->y1})); } Rect const &r=*todo_open[i].second; auto it=active.upper_bound({r.y0, INT64_MAX}); if (it!=active.begin()){ --it; if (not (it->second<=r.y0 or r.y1<=it->first)){ cout<<"no"<