We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 92234ea commit 4f80c04Copy full SHA for 4f80c04
atcoder/lazysegtree.hpp
@@ -4,11 +4,13 @@
4
#include <algorithm>
5
#include <cassert>
6
#include <iostream>
7
+#include <mutex>
8
#include <vector>
9
10
#include "atcoder/internal_bit"
11
12
namespace atcoder {
13
+std::mutex mtx_all_apply, mtx_push;
14
15
template <class S,
16
S (*op)(S, S),
@@ -174,10 +176,12 @@ struct lazy_segtree {
174
176
175
177
void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
178
void all_apply(int k, F f) const {
179
+ std::lock_guard<std::mutex> guard(mtx_all_apply);
180
d[k] = mapping(f, d[k]);
181
if (k < size) lz[k] = composition(f, lz[k]);
182
}
183
void push(int k) const {
184
+ std::lock_guard<std::mutex> guard(mtx_push);
185
all_apply(2 * k, lz[k]);
186
all_apply(2 * k + 1, lz[k]);
187
lz[k] = id();
0 commit comments