test/cpv/library-checker-tree/rooted_tree_isomorphism_classification.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/rooted_tree_isomorphism_classification | ||
| 2 | #include "../../../src/edh/splitmix64/lib.hpp" | ||
| 3 | #include "../../../src/graph/ds/alist/lib.hpp" | ||
| 4 | #include "../../../src/io/container/lib.hpp" | ||
| 5 | #include "../../../src/tree/dfs/hash_rooted/lib.hpp" | ||
| 6 | |||
| 7 | using namespace tifa_libs; | ||
| 8 | 17 | int main() { | |
| 9 | 17 | hash_splitmix64::set_seed(); | |
| 10 |
1/2✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
|
17 | std::cin.tie(nullptr)->std::ios::sync_with_stdio(false); |
| 11 | u32 n; | ||
| 12 |
1/2✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
|
17 | std::cin >> n; |
| 13 | 17 | tree<alist<>> tr(n); | |
| 14 |
2/2✓ Branch 0 taken 4661748 times.
✓ Branch 1 taken 17 times.
|
4661765 | for (u32 i = 1, p; i < n; ++i) { |
| 15 |
1/2✓ Branch 1 taken 4661748 times.
✗ Branch 2 not taken.
|
4661748 | std::cin >> p; |
| 16 | 4661748 | tr.add_arc(i, p), tr.add_arc(p, i); | |
| 17 | } | ||
| 18 | 17 | auto ans = tree_hash_rooted(tr, hash_splitmix64()); | |
| 19 |
1/2✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
|
17 | map<u64, vecu> dict; |
| 20 |
4/6✓ Branch 2 taken 4661765 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4661765 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4661765 times.
✓ Branch 8 taken 17 times.
|
4661782 | flt_ (u32, i, 0, n) dict[ans[i]].push_back(i); |
| 21 |
2/4✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
|
17 | std::cout << dict.size() << '\n'; |
| 22 | 17 | u32 cnt = 0; | |
| 23 |
4/6✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 744650 times.
✓ Branch 11 taken 17 times.
|
744667 | for (auto&& [k, v] : dict) { |
| 24 |
2/2✓ Branch 6 taken 4661765 times.
✓ Branch 7 taken 744650 times.
|
5406415 | for (auto i : v) ans[i] = cnt; |
| 25 |
1/2✓ Branch 1 taken 744650 times.
✗ Branch 2 not taken.
|
744650 | ++cnt; |
| 26 | } | ||
| 27 |
1/2✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
|
17 | std::cout << ans << '\n'; |
| 28 | 17 | return 0; | |
| 29 | 17 | } | |
| 30 |