版本比较
PTZ2021sd3i Intellectual Implementation(扫描线技巧)
正文
增加 6 行删除 6 行
48 行未改动49505152535453545556575830 行未改动899091929394959394959697989913 行未改动113114115116117117118119120121120 行未改动全部展开48 行未改动#ifdef N2#define _GLIBCXX_DEBUG#define LOG(...) fprintf(stderr, __VA_ARGS__)#define DO(...) __VA_ARGS__#define NDO(...) #else #define NDO(...)#else#define LOG(...)#define DO(...)#define NDO(...) __VA_ARGS__#endif30 行未改动 for(auto r : p) numy.emplace_back(r.yl), numy.emplace_back(r.yr); sort(numx.begin(), numx.end()); sort(numy.begin(), numy.end()); for(auto &r : p) { r = Rect(upper_bound(numx.begin(), numx.end(), r.xl) - numx.begin(), upper_bound(numy.begin(), numy.end(), r.yl) - numy.begin(), upper_bound(numx.begin(), numx.end(), r.xr) - numx.begin(), r = Rect(upper_bound(numx.begin(), numx.end(), r.xl) - numx.begin(), upper_bound(numy.begin(), numy.end(), r.yl) - numy.begin(), upper_bound(numx.begin(), numx.end(), r.xr) - numx.begin(), upper_bound(numy.begin(), numy.end(), r.yr) - numy.begin()); } for(int i = 0; i < p.size(); i++) { opt.emplace_back(Seg(p[i].xl, p[i].xr, p[i].yl), i);13 行未改动 while(x <= n) { tr[x] += val; x += __lowbit(x); } } } int __query(int x) { int res = 0; while(x) { res += tr[x];120 行未改动全部展开