#P9414. 「NnOI R1-T3」元组

    ID: 10506 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>O2优化背包 DP树形 DP

「NnOI R1-T3」元组

Background

Little L really likes trees, really likes LCA⁡\operatorname{LCA}, and really likes ordered tuples, so this problem was created.

Problem Description

For a rooted tree with nn nodes (the root is 11), define a strictly increasing ordered pp-tuple (a1,a2,…,ap)(a_1,a_2,\ldots,a_p) to be a level-kk LCA⁡\operatorname{LCA} pp-tuple if and only if:

  • 1≤a1<a2<…<ap≤n1 \le a_1 < a_2 < \ldots < a_p \le n.
  • There exists a node xx such that for any strictly increasing ordered kk-tuple b⊆ab \subseteq a, we have LCA⁡i=1k{bi}=x\operatorname{LCA}_{i=1}^{k}\{b_i\} = x.

Note that LCA⁡(x,y)\operatorname{LCA}(x,y) means the lowest common ancestor of nodes xx and yy in the tree, and LCA⁡i=1k{bi}\operatorname{LCA}_{i=1}^{k}\{b_i\} means the LCA⁡\operatorname{LCA} of all bib_i.

Find the number of level-kk LCA⁡\operatorname{LCA} pp-tuples, modulo 109+710^9+7.

Input Format

The first line contains three integers n,p,kn,p,k.

The next n−1n-1 lines each contain two integers, representing the endpoints of an edge.

Output Format

Output one integer, the required answer.

6 4 3
1 2
2 3
3 4
3 5
3 6
1
6 3 2
1 2
1 3
1 4
1 5
1 6
20
6 4 2
1 2
1 3
2 4
2 5
3 6
0

Hint

Sample 1 Explanation

For sample 11, we find that the only valid 44-tuple is (3,4,5,6)(3,4,5,6).

Constraints

For 100%100\% of the testdata, 2≤n≤50002 \le n \le 5000, and 2≤k≤p≤n2 \le k \le p \le n.

Note: This problem uses bundled testcases.

  • Subtask 1 (10 pts): n≤10n \le 10.
  • Subtask 2 (20 pts): n≤20n \le 20.
  • Subtask 3 (30 pts): n≤500n \le 500.
  • Subtask 4 (10 pts): Node 11 has a direct edge to every node.
  • Subtask 5 (30 pts): No special restrictions.

Contributors

data&check: EstasTonne. (The problem setter of the next problem number under this problem in the problemset.)

Translated by ChatGPT 5