Approach
Segment tree or range structure
For Vertex Add Path Sum, the implementation stores interval information in a range-query data structure so updates and queries avoid rescanning the full input.
- Choose the aggregate stored for each interval or prefix.
- Build or initialize the structure from the input.
- Apply updates and combine the affected nodes to answer each query.
Code notes
- 32 lines of C++ from the credited upstream file yosupo-vertex-add-path-sum.test.cpp.
- The implementation visibly relies on sequence storage, ordered lookup.
- No explicit loop blocks detected.
Complexity
Count the build once, then multiply the logarithmic update or query path by the number of operations.
Check the problem constraints before deciding whether this complexity will pass.