QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 512 MB مجموع النقاط: 100 قابلة للهجوم ✓

#7126. 控制点

الإحصائيات

bobo 有一棵包含 $n$ 个顶点的树。树上有 $m$ 个顶点被 bobo 认为是特殊的。

bobo 想要选择一个(可能是空集的)顶点子集作为控制点,使得每一个特殊顶点到某个控制点的距离不超过 $r$ 条边。

求满足条件的子集数量,结果对 $(10^9 + 7)$ 取模。

输入格式

第一行包含 3 个整数 $n, m, r$ ($1 \le n \le 2000, 0 \le m \le n, 0 \le r < n$)。 顶点编号为 $1, 2, \dots, n$。

第二行包含 $m$ 个不同的整数 $v_1, v_2, \dots, v_m$,表示特殊顶点 ($1 \le v_i \le n$)。

接下来的 $(n-1)$ 行,每行包含 2 个整数 $a_i, b_i$,表示顶点 $a_i$ 和 $b_i$ 之间的一条边 ($1 \le a_i, b_i \le n$)。

输出格式

输出一个整数,表示满足条件的子集数量。

样例

样例输入 1

3 1 1
1
1 2
2 3

样例输出 1

6

样例输入 2

4 1 2
1
1 2
2 3
2 4

样例输出 2

15

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.