#P12059. Exploration Strategies in a Collapsing DFS Tree
Exploration Strategies in a Collapsing DFS Tree
Exploration Strategies in a Collapsing DFS Tree
The world of the Black Cat is coming to an end. In this doomed world, Liki and Sasami must uncover its truth. The world is modeled as a rooted tree with \(n\) nodes numbered \(1\) to \(n\) (with node \(1\) being the root). It is known that there exists a depth-first search (DFS) order such that the i-th visited node is \(i\); in other words, the sequence \(1,2,\dots,n\) is a valid DFS order for the tree.
Initially, all nodes are intact. Each day Liki and Sasami choose one intact node \(u\) to explore. Immediately after their exploration, the Black Cat causes node \(u\) and all nodes in its subtree (with respect to the tree structure) to collapse. In addition, at the end of day \(i\) (after the exploration and collapse of the chosen node), due to the depletion of their powers, node \(n-i+1\) (if it has not already collapsed) will also collapse automatically.
For every \(i\) from \(1\) to \(n\), compute the number of different exploration strategies that result in exactly \(i\) exploration days and the last exploration being at node \(1\) (i.e. on the last day the node chosen to explore is the root). Since the answer can be very large, output it modulo \(998244353\).
Notes:
- The DFS order property means that for every node, its subtree corresponds to a contiguous segment in the order \(1,2,\dots,n\). (All formulas should be interpreted in \(\LaTeX\) format.)
- An exploration on node \(u\) collapses all nodes in the subtree of \(u\) (including \(u\) itself).
- At the end of day \(i\), the node with number \(n-i+1\) will collapse automatically if it is still intact.
inputFormat
The first line contains a single integer \(n\) (\(1 \le n \le 15\)). The next line contains \(n-1\) integers \(p_2, p_3, \dots, p_n\) where \(p_i\) is the parent of node \(i\) in the tree. It is guaranteed that there exists a DFS order of the tree in which the i-th visited node is \(i\).
outputFormat
Output a single line containing \(n\) space‐separated integers. The \(i\)-th integer represents the number of valid exploration strategies that use exactly \(i\) exploration days and have the last explored node equal to \(1\), modulo \(998244353\).
sample
1
1