Logo
(追記) (追記ここまで)

30420번 - Osmanthus Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 1024 MB75360.000%

문제

Eight years ago, Little B saw an osmanthus tree, which is a tree $T$ with $n$ vertices, where the parent vertex of any non-root vertex in $T$ has a smaller label than its own. Given an integer $k,ドル a rooted tree $T'$ with $(n + m)$ vertices is prosperous if and only if the following conditions are met:

  • For any $(i, j)$ with 1ドル \leq i, j \leq n,ドル the lowest common ancestor of vertices $i$ and $j$ in $T$ and $T'$ has the same label.
  • For any $(i, j)$ with 1ドル \leq i, j \leq n + m,ドル the label of the lowest common ancestor of vertices $i$ and $j$ in $T'$ does not exceed $\max(i, j) + k$.

Note that all vertices in the trees are labeled starting from 1ドル,ドル and the label of the root vertex is 1ドル$. $T'$ does not need to satisfy the condition that the parent vertex of any non-root vertex has a smaller label than its own.

Little B wants to know how many trees with $(n + m)$ vertices are prosperous. Two trees are considered different if there exists a vertex whose parent vertex is different in the two trees. Output the number of solutions modulo $(10^9 + 7)$.

입력

This problem has multiple test data sets.

The first line of the input contains two integers $c $ and $t,ドル which represent the test case number and the number of test data sets. $c = 0$ represents that this test case is a sample test.

Then, each set of test data is given as input in order. For each set of test data:

The first line of the input contains three integers $n,ドル $m,ドル and $k$.

The second line of the input contains $n - 1$ integers $f_2, f_3, ..., f_n,ドル where $f_i$ represents the label of the parent vertex of vertex $i$ in $T$.

출력

For each set of test data, output a line containing an integer, representing the number of possible prosperous trees, taken modulo $(10^9+7)$.

제한

For all test data, it is guaranteed that: 1ドル \leq t\leq 15,1\leq n\leq 3\times 10^4,0\leq m\leq 3000,0\leq k\leq 10,1\leq f_i\leq i-1$.

예제 입력 1

0 3
1 2 1
2 2 1
1
2 2 0
1

예제 출력 1

3
16
15

For the first set of test data in the sample, there are three valid trees, with parent sequences of $\{f_2, f_3\}$ being $\{1, 1\},ドル $\{3, 1\},ドル and $\{1, 2\},ドル respectively. Note that the second line in this set of test data is blank.

For the second and third sets of test data in the sample, there are a total of 16ドル$ trees that satisfy the first condition. Among them, only the tree with parent sequence $\{4, 4, 1\}$ does not satisfy the second condition in the third set of test data.

힌트

추가

출처

Olympiad > National Olympiad in Informatics (China) > NOI 2023 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /