1503 : 图神的聚会
时间限制Time Limit
2
秒Sec
内存限制Memory Limit
1024
兆MB
提交次数Submitted
0 次Times
通过次数Solved
0 次Times
标准评测 Standard
从标准输入读入,结果写到标准输出。评测将输出拆成 token,与标准答案逐项比较,不按整段逐字节比对。
Read from standard input and write to standard output. The judge splits the output into tokens and compares them with the official answer; it does not compare raw bytes.
| 比对Compare | token 相同即通过。中间的空格、制表符、换行可多可少。Matching tokens pass. Extra spaces, tabs, or newlines between them are ignored. |
|---|---|
| 不同则错Differs | token 个数或内容不同即错误。23 与 2 3、02 与 2、2.0 与 2 均视为不同。A different token count or value is wrong. 23 vs 2 3, 02 vs 2, and 2.0 vs 2 all differ. |
| 输入Input | 标准输入,格式见题面。Standard input; format as in the statement. |
| 输出Output | 标准输出。Standard output. |
题目描述Description
图神是 ACM 界知名的选手,经常在赛场上大显身手。这次他决定搞一次团建,把各地的好基友聚集到一起。不过,由于预算有限,他只邀请了部分城市中的朋友。
全国共有 n(1 \le n \le 500) 个城市,由 m(1 \le m \le 5000) 条双向道路相连。每条道路都有一个费用 w(1 \le w \le 10^6)。图神只邀请了 k(1 \le k \le min(12,n)) 个城市中的朋友,而图神每次都在不同的地方,图神至少花费多少代价才能使他们聚集到一起。
输入格式Input
第一行:四个整数 n , m , k , q(1 \leq q \leq 500) ,表示有 n 个城市,m 条道路,要邀请 k 个朋友,有 q 次询问 。
接下来 m 行:每行三个整数 u, v , w ,表示编号为 u , v 的城市之间有一条费用为 w 的道路。
接下来一行:k 个互不相同的正整数,表示每个朋友所在的城市。
接下来一行:q 次图神每次所在的城市。
输出格式Output
输出 q 行整数,表示最小费用。
样例Sample
出题Author
xxy