You are given a tree that contains vertices and queries. Each query is determining the number of decompositions of the tree into paths and the path from to that is one of the paths in the decomposition modulo 998244353.↵
↵
A tree decomposition in paths is valid if each vertex belongs to exactly one path. A path can be a single vertex. Two decompositions are different if there are two vertices and that belong to the same path in one of the decompositions but two distinct paths in the other.↵
↵
Sample Input: ↵
↵
<spoiler summary="Sample input">↵
↵
</5 2↵
3 1↵
4 1↵
1 5↵
2 5↵
3 3↵
2 5>↵
↵
↵
<spoiler summary="Sample Output"> : ↵
↵
</8 4>8 ↵
4↵
↵
↵
Can anyone please explain this problem with an example...↵
Problem Link : https://www.hackerearth.com/problem/algorithm/path-decomposition-ii-ad4b4a0c/
↵
A tree decomposition in paths is valid if each vertex belongs to exactly one path. A path can be a single vertex. Two decompositions are different if there are two vertices and that belong to the same path in one of the decompositions but two distinct paths in the other.↵
↵
Sample Input: ↵
↵
↵
</
3 1↵
4 1↵
1 5↵
2 5↵
3 3↵
2 5
↵
↵
4↵
↵
↵
Can anyone please explain this problem with an example...↵
Problem Link : https://www.hackerearth.com/problem/algorithm/path-decomposition-ii-ad4b4a0c/