Skip to content

Commit be10ca2

Browse files
committed
make it work in debug mode
1 parent ef3a965 commit be10ca2

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ template<class F, class G> struct pq_updates {
2929
int l = sz(st), r = l;
3030
for (auto& [_, i] : mp) {
3131
l = min(l, i);
32-
swap(st[i], st[--r]);
33-
swap(st[i].first->second, i);
32+
if (i != --r)
33+
swap(st[i], st[r]), swap(st[i].first->second, i);
3434
if (r - l <= sz(st) - r) break;
3535
}
3636
rep(i, l, sz(st)) undo();

tests/library_checker_aizu_tests/handmade_tests/pq_updates.test.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#define PROBLEM \
22
"https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A"
3-
// swapping iterators in as part of `swap(st[i], st[--r]);`
4-
// leads to RTE with debug mode :(
5-
#undef _GLIBCXX_DEBUG
63
#include "../template.hpp"
74
#include "../../../library/contest/random.hpp"
85
#include "../../../library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp"

0 commit comments

Comments
 (0)