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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#include <bits/stdc++.h> #define all(vec) vec.begin(),vec.end() #define lson(o) (o<<1) #define rson(o) (o<<1|1) #define SZ(a) ((long long) a.size()) #define debug(var) cerr << #var <<":"<<var<<"\n"; #define cend cerr<<"\n-----------\n" #define fsp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long; using ull = unsigned long long; using DB = double;
using CD = complex<double>;
static constexpr ll MAXN = (ll)1e6+10, INF = (1ll<<61)-1; static constexpr ll mod = 998244353; static constexpr double eps = 1e-8; const double pi = acos(-1.0);
ll lT,testcase;
struct Rectangle { ll x,y,w,h; bool operator<(const Rectangle &o) const { if (x+w!=o.x+o.w) { return x+w<o.x+o.w; } return h+y<o.h+o.y; } }; struct Event { ll x,y_st,y_ed,op; bool operator<(const Event & o) const { if (x!=o.x) return x<o.x; return op<o.op;
} };
void Solve() { ll N; cin >> N; ll mnx=INF,mny=INF,mxx=0,mxy=0; ll acc_area=0; multiset<Event> event_st; for (int i=0;i<N;++i) { ll x,y,w,h; cin>>x>>y>>w>>h; mnx=min(mnx,x); mny=min(mny,y); mxx=max(mxx,x+w); mxy=max(mxy,y+h); acc_area+=w*h; event_st.insert({x,y,y+h,1}); event_st.insert({x+w,y,y+h,0}); } set<pair<ll,ll>> activates; auto check=[&](pair<ll,ll> y_pair) -> bool { if (activates.empty()) { return true; } auto it=activates.upper_bound(y_pair); if (it!=activates.end()) { if (y_pair.first>=it->second || y_pair.second<=it->first) {
}else { return false; } } if (it!=activates.begin()) { it=prev(it); if (y_pair.first>=it->second || y_pair.second<=it->first) {
}else { return false; } } return true; }; for (auto &event:event_st) { auto [x,y_st,y_ed,op]=event; if (op==1) { if (!check({y_st,y_ed})) { cout<<"no\n"; return; } activates.insert({y_st,y_ed}); }else { activates.erase({y_st,y_ed}); } } cout<<"yes\n"; }
signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef LOCAL cout.setf(ios::unitbuf); #endif
Solve(); return 0; }
|