From 57c74f6551b098e0d87cbe75b2a03ed0147995a6 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Mon, 21 Sep 2020 12:43:51 -0500 Subject: Minor bug --- Data Structures/segment_tree.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Data Structures/segment_tree.cpp b/Data Structures/segment_tree.cpp index a52502f..b7c6e05 100644 --- a/Data Structures/segment_tree.cpp +++ b/Data Structures/segment_tree.cpp @@ -6,7 +6,7 @@ template struct seg_tree { if (l != r) tmp[n<<1] += tmp[n], tmp[n<<1|1] += tmp[n]; tmp[n] = 0; } - void build(T v, int l = 0, int r = MX, int n = 1) { + void build(T v, int l = 0, int r = MX-1, int n = 1) { if (l == r) seg[n] = v; else { int m = (l+r)>>1; @@ -14,7 +14,7 @@ template struct seg_tree { seg[n] = pull(seg[n<<1], seg[n<<1|1]); } } - void update(int x, T v, int l = 0, int r = MX, int n = 1) { + void update(int x, T v, int l = 0, int r = MX-1, int n = 1) { if (l == r) seg[n] += v; else { int m = (l+r)>>1; @@ -22,7 +22,7 @@ template struct seg_tree { seg[n] = pull(seg[n<<1], seg[n<<1|1]); } } - void update(int a, int b, T v, int l = 0, int r = MX, int n = 1) { + void update(int a, int b, T v, int l = 0, int r = MX-1, int n = 1) { push(l, r, n); if (l > r || l > b || r < a) return; if (l >= a && r <= b) { @@ -35,7 +35,7 @@ template struct seg_tree { seg[n] = pull(seg[n<<1], seg[n<<1|1]); } } - T query(int a, int b, int l = 0, int r = MX, int n = 1) { + T query(int a, int b, int l = 0, int r = MX-1, int n = 1) { if (a > b || l > b || r < a) return 0; push(l, r, n); if (l >= a && r <= b) return seg[n]; -- cgit v1.2.3-70-g09d2