GCC Code Coverage Report


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

test/cpv/library-checker-tree/vertex_add_subtree_sum.hld.cpp
Line Branch Exec Source
1 // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/vertex_add_subtree_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 52003636 T op(T a, T b) { return T{a.first + b.first, a.second + b.second}; }
13 1919727 void mapping(T& a, F f) { a.first += f; }
14 void composition(F& f, F g) { f += g; }
15
16 16 int main() {
17 u32 n, q;
18 16 fin_uint >> n >> q;
19
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
32 vecii b(n);
20
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 vec<T> a(n);
21
2/2
✓ Branch 6 taken 4115189 times.
✓ Branch 7 taken 16 times.
4115205 for (auto& x : b) fin_uint >> x;
22 16 tree_t tr_(n);
23
2/2
✓ Branch 2 taken 4115173 times.
✓ Branch 3 taken 16 times.
4115189 for (u32 i = 1, p; i < n; ++i) fin_uint >> p, tr_.add_arc((u32)p, (u32)i);
24 16 hld<tree_t, T, op, F, mapping, composition> tr({0, 0}, 0, tr_);
25
2/2
✓ Branch 5 taken 4115189 times.
✓ Branch 6 taken 16 times.
4115205 flt_ (u32, i, 0, n) a[tr.info.dfn[i]].first = b[i], a[tr.info.dfn[i]].second = 1;
26 16 tr.build(a);
27
2/2
✓ Branch 0 taken 3837215 times.
✓ Branch 1 taken 16 times.
3837231 for (u32 i = 0, opt, u; i < q; ++i) {
28 3837215 fin_uint >> opt >> u;
29
2/2
✓ Branch 0 taken 1919727 times.
✓ Branch 1 taken 1917488 times.
3837215 if (opt == 0) {
30 i64 x;
31 1919727 fin_uint >> x;
32 1919727 tr.node_update((u32)u, x);
33 1917488 } else fout << tr.subtree_query((u32)u).first << '\n';
34 }
35 16 return 0;
36 16 }
37