There was an error while loading. Please reload this page.
1 parent 46bc4da commit 3e2a465Copy full SHA for 3e2a465
1 file changed
library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp
@@ -27,18 +27,17 @@ template<class F, class G> struct pq_updates {
27
st.emplace_back(mp.emplace(pri, sz(st)), upd_params);
28
}
29
void pop() {
30
- int j = sz(st), t = j - 1;
31
- for (auto it = rbegin(mp);
32
- 2 * (sz(st) - j) < sz(st) - t; it++) {
33
- t = min(t, it->second);
34
- if (--j != it->second) {
35
- swap(st[j], st[it->second]);
+ int r = sz(st), l = r - 1;
+ for (auto it = rbegin(mp); r - l > sz(st) - r; it++) {
+ l = min(l, it->second);
+ if (--r != it->second) {
+ swap(st[r], st[it->second]);
36
swap(it->second, st[it->second].first->second);
37
38
39
- rep(i, t, sz(st)) undo();
+ rep(i, l, sz(st)) undo();
40
mp.erase(st.back().first);
41
st.pop_back();
42
- rep(i, t, sz(st)) upd(st[i].second);
+ rep(i, l, sz(st)) upd(st[i].second);
43
44
};
0 commit comments