No.3315 FPS Game
Problem Statement
Aki is playing a certain FPS (First Person Shooter) game.
First, a tree with $N$ vertices is given, where edge $i$ connects vertex $U_i$ and vertex $V_i$.
In this game, edge $i$ corresponds to stage $i$ of the game, and the game starts from stage $S$.
Aki can clear each stage in exactly $1$ minute, and after clearing it, can move to a stage corresponding to an edge that shares one vertex with the edge of the current stage.
However, a stage that has been cleared once becomes locked and can never be visited again during $1$ game.
Aki wants to clear stage $T$.
For each integer $k$ such that $1 ≤ k ≤ N$, find the number of ways to clear stage $T$ in a total of $k$ minutes, modulo $998244353$.
Two ways of clearing are distinguished if and only if their total times differ, or the stages being played differ at some point in time after the start.
The play time includes only the time taken to clear each stage.
Input
$N\ S\ T$
$U_1\ V_1$
$\vdots$
$U_{N-1}\ V_{N-1}$
- All inputs are integers.
- $3 ≤ N ≤ 10^5$
- $1 ≤ S < T ≤ N-1$
- $1 ≤ U_i < V_i ≤ N$
- The given graph is a tree.
Output
Output the answers for $k = 1,\ 2,\ …,\ N$ in order on $1$ line, separated by single spaces, followed by a newline at the end.
Sample
Sample 1
Input
6 1 3 1 2 2 3 3 4 2 5 3 6
Output
0 0 1 2 1 0
In this game, the ways to start from stage $1$ and clear stage $3$ are the following $4$ ways, in order from shortest.
- $1 → 2 → 3$
- $1 → 4 → 2 → 3$
- $1 → 2 → 5 → 3$
- $1 → 4 → 2 → 5 → 3$
Sample 2
Input
8 2 7 1 5 5 8 5 7 3 5 2 5 5 6 4 5
Output
0 1 5 20 60 120 120 0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
kidodesu