QOJ.ac

QOJ

Süre Sınırı: 0.5 s Bellek Sınırı: 64 MB Toplam puan: 100

#23808. JOI 国的购物实情

İstatistikler

题目描述

在 JOI 国有 $N$ 个城镇,它们之间由 $M$ 条可以双向通行的道路相连。有 $K$ 个城镇建有购物中心,国民通过道路前往这些城镇中的某一个进行购物。

根据房屋所在位置的不同,为了去购物可能需要移动很长的距离,这非常不便。为了掌握这一实情,国王决定调查:根据房屋位置的不同,到建有购物中心的城镇的最短距离最长会达到多少。由于房屋也可能建在道路途中(参见样例 $1$ 的解释),这项调查非常困难。因此,国王委托身为优秀程序员的你编写进行调查的程序。

给定道路的信息以及建有购物中心的城镇的信息,请编写一个程序,求出从建有购物中心的城镇到最远的道路上的点(包括端点)的距离。在城镇内部移动所需的距离可以忽略不计。

输入格式

从标准输入读入以下输入:

  • 第 $1$ 行包含以空格分隔的整数 $N, M, K$。$N$ 表示 JOI 国的城镇个数,$M$ 表示 JOI 国的道路条数,$K$ 表示建有购物中心的城镇个数。城镇编号为 $1, 2, \dots, N$。
  • 接下来的 $M$ 行表示道路的信息。第 $(i + 1)$ 行($1 \le i \le M$)包含以空格分隔的整数 $a_i, b_i, l_i$($1 \le a_i \le N, 1 \le b_i \le N, 1 \le l_i \le 1000$)。这表示第 $i$ 条道路连接城镇 $a_i$ 与城镇 $b_i$,且长度为 $l_i$。道路的两端不会是同一个城镇。此外,对于任意 $2$ 个城镇 $p, q$,连接 $p$ 与 $q$ 的道路不会有 $2$ 条或以上。从任意城镇都可以沿着若干条道路到达任意城镇。
  • 接下来的 $K$ 行表示购物中心的信息。第 $(i + M + 1)$ 行($1 \le i \le K$)包含 $1$ 个整数 $s_i$($1 \le s_i \le N$)。这表示城镇 $s_i$ 中建有购物中心。$s_1, \dots, s_K$ 中不会有相同的值出现 $2$ 次或以上。

输出格式

向标准输出输出 $1$ 个整数,表示到建有购物中心的城镇的最短距离的最大值对小数点后进行四舍五入所得的整数。

样例

样例 1

输入
3 3 1
1 2 1
2 3 1
3 1 1
1
输出
2
解释

输入样例 $1$ 表示如下图所示的城镇。所有道路的长度均为 $1$。购物中心仅在城镇 $1$ 中有。

距离建有购物中心的城镇最远的点,位于连接城镇 $2$ 与城镇 $3$ 的道路上距离城镇 $2$ 为 $0.5$ 的位置,其到建有购物中心的城镇的距离为 $1.5$。因此,输出将其四舍五入后的值 $2$。

fig1

样例 2

输入
4 5 2
1 2 4
1 3 1
2 3 2
2 4 2
3 4 1
2
4
输出
3

数据范围与提示

  • $2 \le N \le 3000$:JOI 国的城镇个数。
  • $1 \le M \le 100000 = 10^5$:JOI 国的道路条数。
  • $1 \le K \le N$:建有购物中心的城镇个数。
  • $1 \le l_i \le 1000$:第 $i$ 条道路的长度。

计分基准

  • 在占总分 $40\%$ 的测试数据中,满足 $K = 1$。

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.