Skip to content

Commit

Permalink
Update dynamic.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
radicalparty authored Jul 12, 2024
1 parent 127d974 commit 30c538b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions data_structure/segtree/dynamic.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//reference: https://justicehui.github.io/medium-algorithm/2020/02/28/DynamicSeg/
struct Node{
Node *l, *r;
ll tsum;
ll tsum;//구간 합
Node(): l(nullptr), r(nullptr), tsum(0) {}
};
void update(Node *node, int s, int e, int p, ll val){
if (s == e){
node->tsum = val; return;
}
int m = (s + e) >> 1;
if (p <= m){
if (p <= m){//l, r을 반으로 나눠서 구간 선택, 나머지는 일반적인 세그와 동일
if (!node->l) node->l = new Node();
update(node->l, s, m, p, val);
}
Expand Down

0 comments on commit 30c538b

Please sign in to comment.