QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 100

#2578. Minimax Search

统计

Minimax Search

Keliang is a girl who loves playing games. To improve her gaming skills, she wants to arm herself with theoretical weapons. This problem is related to the famous Minimax search.

Keliang has a rooted tree with the root node labeled 1. The depth of the root node is defined as 1, and the depth of any other node is the depth of its parent plus one. Given the values of the leaf nodes, Keliang defines the value of every non-leaf node as follows:

  • For a non-leaf node at an odd depth, its value is the maximum of the values of all its children.
  • For a non-leaf node at an even depth, its value is the minimum of the values of all its children.

Initially, Keliang sets the value of the leaf node labeled $i$ to $i$, and calculates the value of the root node as $W$.

Now, the evil Cedyks wants to change the value of the root node by modifying the values of some leaf nodes. Cedyks has designed a quantum attacker. After the attacker is activated, Cedyks randomly gains control over a non-empty subset of leaf nodes $S$ and can spend a certain amount of energy to modify the values of the leaf nodes in $S$.

However, modifying the values of leaf nodes consumes energy. For a leaf node $i \in S$ with an initial value $i$, if Cedyks changes its value to $w_i$ (where $w_i$ can be any integer, including negative integers), the energy cost for this attack is $\max_{i \in S} |i - w_i|$.

Cedyks wants to save as much energy as possible, so he will always perform the attack with the minimum energy required to change the root node's value. Let $w(S)$ be the energy Cedyks spends after gaining control of the subset $S$. Specifically, for some subsets $S$, it may be impossible to change the root node's value regardless of how the values of the leaf nodes in $S$ are modified; in this case, $w(S)$ is defined as $n$. For convenience, we call $w(S)$ the stability of $S$.

When there are $m$ leaf nodes, there are $2^m - 1$ different non-empty subsets of leaf nodes. Before launching the attack, Cedyks wants to estimate the energy he needs to spend. He provides an interval $[L, R]$ and wants to know, for each $k \in [L, R]$, how many subsets $S$ satisfy $w(S) = k$.

Input

The first line contains three integers $n, L, R$ ($n \ge 2, 1 \le L \le R \le n$).

The next $n - 1$ lines each contain two integers $u, v$, representing an edge in the tree.

Output

Output a single line containing $R - L + 1$ integers, where the $i$-th integer represents the number of subsets $S$ such that $w(S) = L + i - 1$. Since the answer can be very large, output it modulo 998244353.

Examples

Input 1

5 1 5
1 5
1 4
5 3
5 2

Output 1

4 0 1 0 2

Note

Initially, under Keliang's setting (the value of leaf node $i$ is $i$), the root node's value is 4.

There are 3 leaf nodes $\{2, 3, 4\}$ in the tree, and a total of 7 non-empty subsets of leaf nodes. Among them:

  • The stability of $\{4\}, \{2,4\}, \{3,4\}, \{2,3,4\}$ is 1, because by slightly modifying the value of leaf node 4, the root node's value will change.
  • The stability of $\{2\}, \{3\}$ is 5, because the value of node 5 is the minimum of the values of 2 and 3. If only node 2 or node 3 is modified, the value of node 5 will always be less than or equal to 3, so the root node's value will always be 4.
  • The stability of $\{2,3\}$ is 3. To change the root node's value, the value of node 5 must be greater than 4, which requires both $w_2$ and $w_3$ to be greater than 4. Thus, the stability is 3; one feasible strategy is to set both $w_2, w_3$ to 5.

Constraints

Test Case $n$ Other Constraints
1 $\le 10$ $L = R = n$
2 $\le 50$ $L = R = n$
3 $\le 5000$ $L = R = n$
4 $\le 5000$ $L = R = n$
5 $\le 5000$ $L = R = n$
6 $\le 2 \times 10^5$ $R - L \le 50$
7 $\le 2 \times 10^5$ $R - L \le 50$
8 $\le 2 \times 10^5$ None
9 $\le 2 \times 10^5$ None
10 $\le 2 \times 10^5$ None

For 100% of the data, $n \ge 2, 1 \le L \le R \le n$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.