Skip to content

Commit 3e2a465

Browse files
committed
golf
1 parent 46bc4da commit 3e2a465

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@ template<class F, class G> struct pq_updates {
2727
st.emplace_back(mp.emplace(pri, sz(st)), upd_params);
2828
}
2929
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]);
30+
int r = sz(st), l = r - 1;
31+
for (auto it = rbegin(mp); r - l > sz(st) - r; it++) {
32+
l = min(l, it->second);
33+
if (--r != it->second) {
34+
swap(st[r], st[it->second]);
3635
swap(it->second, st[it->second].first->second);
3736
}
3837
}
39-
rep(i, t, sz(st)) undo();
38+
rep(i, l, sz(st)) undo();
4039
mp.erase(st.back().first);
4140
st.pop_back();
42-
rep(i, t, sz(st)) upd(st[i].second);
41+
rep(i, l, sz(st)) upd(st[i].second);
4342
}
4443
};

0 commit comments

Comments
 (0)