Skip to content

Commit 16a0523

Browse files
authored
Merge pull request #12 from SuprDewd/mnnode_fix
Fix potential overflow in segment_tree_mnnode
2 parents 272d8f7 + ea2b68f commit 16a0523

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

code/data-structures/segment_tree_mnnode.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#define STNODE
33
struct node {
44
int l, r;
5-
int x, lazy;
5+
ll x, lazy;
66
node() {}
77
node(int _l, int _r) : l(_l), r(_r), x(INF), lazy(0) { }
8-
node(int _l, int _r, int _x) : node(_l,_r) { x = _x; }
8+
node(int _l, int _r, ll _x) : node(_l,_r) { x = _x; }
99
node(node a, node b) : node(a.l,b.r) { x = min(a.x, b.x); }
10-
void update(int v) { x = v; }
11-
void range_update(int v) { lazy = v; }
10+
void update(ll v) { x = v; }
11+
void range_update(ll v) { lazy = v; }
1212
void apply() { x += lazy; lazy = 0; }
1313
void push(node &u) { u.lazy += lazy; } };
1414
#endif

0 commit comments

Comments
 (0)