MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / build

Function build

code/data-structures/persistent_segment_tree.cpp:5–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3 int l, r, lid, rid, sum;
4} segs[2000000];
5int build(int l, int r) {
6 if (l > r) return -1;
7 int id = segcnt++;
8 segs[id].l = l;
9 segs[id].r = r;
10 if (l == r) segs[id].lid = -1, segs[id].rid = -1;
11 else {
12 int m = (l + r) / 2;
13 segs[id].lid = build(l , m);
14 segs[id].rid = build(m + 1, r); }
15 segs[id].sum = 0;
16 return id; }
17int update(int idx, int v, int id) {
18 if (id == -1) return -1;
19 if (idx < segs[id].l || idx > segs[id].r) return id;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected