GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 95.5% 21 / 0 / 22
Functions: 75.0% 3 / 0 / 4
Branches: 85.7% 12 / 0 / 14

test/cpv/library-checker-tree/vertex_add_path_sum.cpp
Line Branch Exec Source
1 // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/vertex_add_path_sum
2 #include "../../../src/graph/ds/alist/lib.hpp"
3 #include "../../../src/io/fastin/lib.hpp"
4 #include "../../../src/io/fastout/lib.hpp"
5 #include "../../../src/tree/hld/lib.hpp"
6
7 using namespace tifa_libs;
8 using T = std::pair<i64, i32>;
9 using F = i64;
10 using tree_t = tree<alist<>>;
11
12 128502362 T op(T a, T b) { return T{a.first + b.first, a.second + b.second}; }
13 2413000 void mapping(T& a, F f) { a.first += f; }
14 void composition(F& f, F g) { f += g; }
15
16 19 int main() {
17 u32 n, q;
18 19 fin_uint >> n >> q;
19
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
38 vecii b(n);
20
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
19 vec<T> a(n);
21
2/2
✓ Branch 6 taken 5614014 times.
✓ Branch 7 taken 19 times.
5614033 for (auto& x : b) fin_uint >> x;
22 19 tree_t tr_(n);
23
2/2
✓ Branch 4 taken 5613995 times.
✓ Branch 5 taken 19 times.
5614014 for (u32 i = 1, u, v; i < n; ++i) fin_uint >> u >> v, tr_.add_arc((u32)u, (u32)v), tr_.add_arc((u32)v, (u32)u);
24 19 hld<tree_t, T, op, F, mapping, composition> tr({0, 0}, 0, tr_);
25
2/2
✓ Branch 5 taken 5614014 times.
✓ Branch 6 taken 19 times.
5614033 flt_ (u32, i, 0, n) a[tr.info.dfn[i]].first = b[i], a[tr.info.dfn[i]].second = 1;
26 19 tr.build(a);
27
2/2
✓ Branch 0 taken 5333119 times.
✓ Branch 1 taken 19 times.
5333138 for (u32 i = 0, opt, u; i < q; ++i) {
28 5333119 fin_uint >> opt >> u;
29
2/2
✓ Branch 0 taken 2413000 times.
✓ Branch 1 taken 2920119 times.
5333119 if (opt == 0) {
30 i64 x;
31 2413000 fin_uint >> x;
32 2413000 tr.node_update((u32)u, x);
33 } else {
34 u32 v;
35 2920119 fin_uint >> v;
36 2920119 fout << tr.chain_query((u32)u, (u32)v).first << '\n';
37 }
38 }
39 19 return 0;
40 19 }
41