QOJ.ac

QOJ

時間限制: 3 s 記憶體限制: 1024 MB 總分: 100

#3956. 炸弹

统计

你的团队发现可怕的全球霸主局(BGO)制定了一个统治世界的计划;拯救世界免于毁灭的唯一方法就是炸毁 BGO 总部。

你手头有 $k$ 枚炸弹,一位专家分析了总部极其复杂的平面图,并指出了放置它们的最佳房间。

Pixabay License, OpenClipart-Vectors

最后一个问题是,BGO 总部的门上有一种相当奇特的监控系统;炸弹的“可疑度”刚好略低于门禁系统每天所能接受的阈值。因此,每天每扇门只能通过一枚炸弹。此外,监控系统基于一种超先进的波技术,会让炸弹感到非常不适——因此,每枚炸弹每天也只能通过一扇门。

假设你的潜行技能让你拥有无限的访问权限,那么放置这些炸弹需要多少天?

输入格式

第一行包含三个空格分隔的整数 $n, m$ 和 $k$。第一个整数 $1 \le n \le 100$ 表示 BGO 总部中的房间数量;房间编号从 $1$ 到 $n$(包含 $1$ 和 $n$)。为简单起见,我们将外部(所有炸弹最初所在的位置)记为房间 $0$。

第二个整数 $1 \le m \le 400$ 表示总部中房间之间的门数。注意,同一房间之间可能有多扇门,且有些门可能通向外部。第三个整数 $1 \le k \le 8$ 表示炸弹的数量。

第二行包含 $k$ 个空格分隔的整数 $b_1, b_2, \dots, b_k$,表示应该放置炸弹的房间(对于每个 $i$,都有 $1 \le b_i \le n$)。

最后有 $m$ 行,每行描述一扇门。每行包含两个不同的空格分隔的整数 $0 \le u, v \le n$,表示房间 $u$ 和房间 $v$ 之间有一扇门。

输出格式

输出一个整数,表示放置炸弹所需的最少天数。

样例

输入格式 1

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

输出格式 1

3

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.