#P5281. [ZJOI2019] Minimax搜索

[ZJOI2019] Minimax搜索

Description

Jiutiao Keliansi is a girl who likes playing games. To improve her gaming skills, she wants to arm herself with theory. This problem is related to the famous Minimax search.

Keliansi has a rooted tree with the root numbered 11. Define the depth of the root as 11, and the depth of any other node as its parent’s depth plus 11. Given the values on the leaf nodes, Keliansi defines the value of each non-leaf node as follows:

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

At the beginning, Keliansi sets the value of the leaf node numbered ii to be ii, and computes the root’s value as WW.

Now, the evil Cedyks wants to change the root’s value by modifying the values of some leaf nodes. Cedyks has designed a quantum attacker. After it is activated, Cedyks will randomly gain control of a non-empty set of leaf nodes SS, and can spend some energy to modify the values of the leaf nodes in SS.

However, modifying leaf node values costs energy. For a leaf node iSi \in S, its initial value is ii. Suppose Cedyks changes its value to wiw_i (wiw_i can be any integer, including negative numbers). Then the energy needed for this attack is maxiSiwi\max_{i\in S} |i − w_i|.

Cedyks wants to save as much energy as possible, so he will always complete the attack with the minimum energy, i.e. under the minimum energy cost, make the root’s value change. Let w(S)w(S) be the energy Cedyks will spend after gaining control of set SS. In particular, for some sets SS, no matter how the values of the leaf nodes in SS are changed, the root’s value will not change. In this case, w(S)w(S) is defined as nn. For convenience, we call w(S)w(S) the stability of SS.

When there are mm leaf nodes, there are 2m12^m − 1 different non-empty sets of leaf nodes. Before launching the attack, Cedyks wants to estimate the energy he may need. So he gives an interval [L,R][L, R], and wants to know, for each k[L,R]k \in [L, R], how many sets SS satisfy w(S)=kw(S) = k.

Input Format

The first line contains three integers n,L,R(n2,1LRn)n, L, R(n ≥ 2,1 \leq L \leq R \leq n).

The next n1n - 1 lines each contain two integers u,vu, v, indicating an edge in the tree.

Output Format

Output one line with RL+1R-L+1 integers. The ii-th integer indicates how many sets SS have w(S)=L+i1w(S) = L+i-1. The answer may be very large; output it modulo 998244353998244353.

5 1 5
1 5
1 4
5 3
5 2
4 0 1 0 2

Hint

Explanation of Sample 1

At the beginning, under Keliansi’s setting (the value of leaf node ii is ii), the root’s value is 44.

There are 33 leaf nodes {2,3,4}\{2,3,4\} in the tree, and there are 77 non-empty sets of leaf nodes, among which:

  • {4},{2,4},{3,4},{2,3,4}\{4\}, \{2,4\}, \{3,4\}, \{2,3,4\} have stability 11. As long as you slightly modify the value of leaf node 44, the root’s value will change.
  • {2},{3}\{2\}, \{3\} have stability 55, because the value at node 55 is the smaller one between 22 and 33. If you only modify node 22 or only modify node 33, the value at node 55 is always less than or equal to 33, so the root’s value is always 44.
  • {2,3}\{2,3\} has stability 33. To make the root’s value change, the value at node 55 must be greater than 44, so both w2w_2 and w3w_3 must be greater than 44. Therefore the stability is 33. One feasible plan is to set both w2w_2 and w3w_3 to 55.

Constraints

Test Point nn Other Constraints Test Point nn Other Constraints
11 10\le10 L=R=nL=R=n 66 2×105\le2\times 10^5 RL50R-L\le50
22 50\le50 77
33 88 None
44 5×103\le5\times 10^3 99
55 1010

For all testdata, it is guaranteed that n2n\ge2, 1LRn1\le L \le R \le n.

Translated by ChatGPT 5