Skip to content

Commit bf92735

Browse files
committed
one line shorter now
1 parent e313a20 commit bf92735

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
@@ -19,26 +19,25 @@
1919
template<class F, class G> struct pq_updates {
2020
F update;
2121
G undo;
22-
using upd = pair<multimap<int, int>::iterator, int>;
23-
vector<upd> st;
22+
vector<pair<multimap<int, int>::iterator, int>> st, buf;
2423
multimap<int, int> mp;
2524
pq_updates(F update, G undo):
2625
update(update), undo(undo) {}
2726
void pop() {
28-
vector<upd> extra;
27+
buf.clear();
2928
int t = sz(st) - 1;
30-
for (auto it = rbegin(mp); 2 * sz(extra) < sz(st) - t;
29+
for (auto it = rbegin(mp); 2 * sz(buf) < sz(st) - t;
3130
it++) {
32-
extra.push_back(st[it->second]);
31+
buf.push_back(st[it->second]);
3332
t = min(t, it->second);
3433
it->second = -1;
3534
}
3635
rep(i, t, sz(st)) undo();
37-
ranges::reverse_copy(extra,
36+
ranges::reverse_copy(buf,
3837
remove_if(t + all(st),
39-
[](upd& x) { return x.first->second == -1; }));
38+
[](auto& x) { return x.first->second == -1; }));
4039
st.pop_back();
41-
mp.erase(extra[0].first);
40+
mp.erase(buf[0].first);
4241
rep(i, t, sz(st)) {
4342
update(st[i].second);
4443
st[i].first->second = i;

0 commit comments

Comments
 (0)