QOJ.ac

QOJ

実行時間制限: 0.5 s メモリ制限: 64 MB 満点: 100

#23808. Shopping in JOI Kingdom

統計

Problem Statement

In JOI Kingdom, there are $N$ towns, and they are connected by $M$ bidirectional roads. There are shopping malls in $K$ towns, and the citizens travel along the roads to one of those towns to go shopping.

Depending on the location of a house, it may be necessary to travel a long distance to go shopping, which is very inconvenient. To grasp this actual situation, the King decided to investigate how long the shortest distance to a town with a shopping mall can be depending on the location of a house. Since a house may be built in the middle of a road (see the explanation for Sample $1$), this investigation is very difficult. Therefore, the King has asked you, an excellent programmer, to write a program that performs the investigation.

Given the information of the roads and the information of the towns with shopping malls, write a program to find the distance from the towns with shopping malls to the farthest point on a road (including endpoints). You may ignore the distance required to move within a town.

Input

Read the following input from Standard Input:

  • The $1$-st line contains the integers $N, M, K$ separated by spaces. $N$ represents the number of towns in JOI Kingdom, $M$ represents the number of roads in JOI Kingdom, and $K$ represents the number of towns with shopping malls, respectively. The towns are numbered $1, 2, \dots, N$.
  • The following $M$ lines represent the information of the roads. The $(i + 1)$-th line ($1 \le i \le M$) contains the integers $a_i, b_i, l_i$ ($1 \le a_i \le N, 1 \le b_i \le N, 1 \le l_i \le 1000$) separated by spaces. This means that the $i$-th road connects town $a_i$ and town $b_i$, and has length $l_i$. Both ends of a road are never the same town. Also, for any $2$ towns $p, q$, there are never $2$ or more roads connecting $p$ and $q$. It is possible to travel from any town to any town by following some roads.
  • The following $K$ lines represent the information of the shopping malls. The $(i + M + 1)$-th line ($1 \le i \le K$) contains $1$ integer $s_i$ ($1 \le s_i \le N$). This means that there is a shopping mall in town $s_i$. The same value never appears $2$ or more times among $s_1, \dots, s_K$.

Output

Output $1$ integer to Standard Output: the maximum shortest distance to a town with a shopping mall, rounded to the nearest integer (with halves rounded up).

Sample

Sample 1

Input
3 3 1
1 2 1
2 3 1
3 1 1
1
Output
2
Explanation

Sample $1$ represents the towns shown in the figure below. The lengths of the roads are all $1$. There is a shopping mall only in town $1$.

The point farthest from a town with a shopping mall is the point on the road connecting town $2$ and town $3$ at a distance of $0.5$ from town $2$, and its distance to the town with a shopping mall is $1.5$. Therefore, output $2$, which is the value rounded to the nearest integer.

fig1

Sample 2

Input
4 5 2
1 2 4
1 3 1
2 3 2
2 4 2
3 4 1
2
4
Output
3

Constraints

  • $2 \le N \le 3000$: the number of towns in JOI Kingdom.
  • $1 \le M \le 100000 = 10^5$: the number of roads in JOI Kingdom.
  • $1 \le K \le N$: the number of towns with a shopping mall.
  • $1 \le l_i \le 1000$: the length of the $i$-th road.

Scoring

  • For test cases worth $40\%$ of the total score, $K = 1$ holds.

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.