QOJ.ac

QOJ

时间限制: 5.0 s 内存限制: 2048 MB 总分: 100

#15941. 送货

统计

你经营着一家快递公司,必须部署一支车队来向客户送货。所有的货物和送货卡车最初都位于你的仓库。

道路网络由路口之间的单向街道组成。仓库和客户都位于某个路口。你已知通过每条街道所需的行驶时间。

你承诺极速送达:卡车在一天开始时立即出发,每个客户 $i$ 将在时间 $T_i$ 收到包裹,其中 $T_i$ 是卡车从仓库到客户 $i$ 所在位置的最短可能行驶时间。

要确保这一承诺得到满足,你最少需要部署多少辆卡车?也就是说,最少需要多少辆卡车,才能为每辆卡车规划一条行驶路线,使得每个客户 $i$ 都能在时间 $T_i$ 被某辆卡车访问。假设在一天开始时将相应的货物装上卡车不需要时间,且卡车到达客户处时卸货也不需要时间。这些货物足够小,以至于每辆卡车都可以根据需要装载任意多客户的货物。

Photo by kamyar adl cc by-sa 2.0

输入格式

输入仅包含单组测试数据。

第一行包含三个整数 $N$、$M$ 和 $C$。其中 $N$ 表示道路网络中的路口数量($2 \le N \le 10^3$),$M$ 表示街道数量($1 \le M \le 10^5$),$C$ 表示客户数量($1 \le C \le 300$,$C < N$)。

路口编号为 $0$ 到 $N - 1$。仓库始终位于路口 $0$。

第二行包含 $C$ 个互不相同的整数,介于 $1$ 到 $N - 1$ 之间,表示客户所在的路口。

接下来的 $M$ 行,每行包含三个整数 $U, V, W$,其中 $0 \le U, V \le N - 1$ 且 $U \neq V$。这表示存在一条从 $U$ 到 $V$ 的单向街道,行驶时间为 $W$。每条街道的行驶时间 $W$ 满足 $1 \le W \le 10^9$。

保证从仓库总是可以到达每个客户。

从顶点 $U$ 到另一个顶点 $V$ 最多只有一条街道,但可能同时存在从 $U$ 到 $V$ 和从 $V$ 到 $U$ 的街道。

输出格式

输出一个整数,表示确保每个客户 $i$ 都在时间 $T_i$ 被某辆车访问所需的最少车辆数。

样例

输入样例 1

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

输出样例 1

2

输入样例 2

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

输出样例 2

3

输入样例 3

8 11 5
1 3 4 6 7
0 1 5
0 4 1
0 2 2
0 6 6
2 3 1
2 6 3
3 5 7
4 1 5
5 7 3
6 5 6
4 6 4

输出样例 3

3

说明

在第一个样例中,一辆车可以沿着路径 $(0, 1, 2)$ 行驶,另一辆车可以沿着 $(0, 3)$ 行驶。

在第二个样例中,唯一的解决方案是使用路径 $(0, 1)$、$(0, 2)$ 和 $(0, 3)$。

在最后一个样例中,一辆车可以沿着 $(0, 1)$ 行驶,另一辆车沿着 $(0, 4, 6)$ 行驶,最后一辆车沿着 $(0, 2, 3, 5, 7)$ 行驶。

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.