test/cpv/library-checker-tree/lca.linear.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/lca | ||
| 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/lca_linear/lib.hpp" | ||
| 6 | |||
| 7 | using namespace tifa_libs; | ||
| 8 | 25 | int main() { | |
| 9 | u32 n, q; | ||
| 10 | 25 | fin_uint >> n >> q; | |
| 11 | 25 | alist<> t(n); | |
| 12 |
2/2✓ Branch 3 taken 10224902 times.
✓ Branch 4 taken 25 times.
|
10224927 | for (u32 i = 1, x; i < n; ++i) fin_uint >> x, t.add_arc(i, x), t.add_arc(x, i); |
| 13 | 25 | lca_linear lca(t); | |
| 14 |
2/2✓ Branch 0 taken 9662271 times.
✓ Branch 1 taken 25 times.
|
9662296 | for (u32 i = 0, u, v; i < q; ++i) { |
| 15 | 9662271 | fin_uint >> u >> v; | |
| 16 | 9662271 | fout << lca(u, v) << '\n'; | |
| 17 | } | ||
| 18 | 25 | return 0; | |
| 19 | 25 | } | |
| 20 |