luogu#P3461. [POI2007] KOL-Railway
[POI2007] KOL-Railway
题目背景
征求翻译。如果你能提供翻译或者题意简述,请直接发讨论,感谢你的贡献。
题目描述
Byteland Railways encountered a necessity of restructuring and reduction of the rail network.
After a deep analysis of of the rail network it has been decided which railway stations will be removed and which ones will stay.
It has been also decided that the rail network should be reduced as far as possible.
It remains to choose which railway lines should be removed and which ones should stay.
The rail network is composed of rail segments connecting railway stations.
It is known that from each station one can travel to every other station (potentially visiting some intermediate stations).
Rail segments are bidirectional.
There can be at most one rail segment connecting each pair of stations.
Each segment can be assigned a cost of maintenance, which is a positive integer.
The rail segments that will remain should be chosen in such way that:
it is possible to travel between every pair of stations that are not going to be removed, their total cost of maintenance is low (it can be at most two times greater than the lowest cost that can be achieved, assuming that the previous condition is satisfied).
All remaining rail segments will be removed.
Railway lines that will remain can run through stations that will be removed.
TaskWrite a programme which:
reads a description of the rail network and the stations that will not be removed from the standard input, determines which rail segments should remain and which should be removed, writes out the rail segments that should remain together with the total cost of their maintenance to the standard output.
输入格式
The first line of input contains two positive integers and , , (), separated by a single space.
denotes the number of railway stations and is the number of rail segments.
Railway stations are numbered from to .
The following lines contain descriptions of the rail segments, one per line.
Each of these lines contains three positive integers , and ,,,.
and are the numbers of stations that are connected by the segment and is its cost of maintenance.
The 'th line contains a sequence of integers separated by single spaces.
The first one of them is - the number of stations that should remain (, ).
It is followed by the numbers of these stations in increasing order.
输出格式
The first line of output should contain two integers and separated by a single space, where is the total cost of maintenance of the segments that should remain and is the number of these segments.
Each of the following lines should contain two integers and , separated by a single space - the numbers of stations that are connected by the segment.
The total cost of maintenance of the segments can be at most two times greater than the lowest achievable total cost.
题目大意
题目描述
出言不逊铁路系统需要重新布置。通过对铁路网络深入的分析,有一些站点需要被移除,有一些道路也需要被移除。 整个铁路网络可以看做一张由 个点, 条道路组成的无向图。从每一个点出发都可以通过直接或间接的道路到达其它所有点。两个站点之间最多只有一条道路。每一条道路都有一个正整数费用。你的任务是决定哪些点和道路需要被保留。 要求:
1.从每一个没被移除的点出发都能通过直接或间接的没被移除的道路到达其他所有没被移除的点。
2.剩下的道路的费用总和要比较小,即不能超过最优解的两倍。
输入格式
第一行包含两个正整数 、(,),表示点数和边数。 接下来 行,每行包含三个正整数 、、(、,,),表示 和 之间有一条费用为 的道路。 最后一行的开头为一个正整数 (,),表示必须要保留的点数。 接下来包含 个正整数,按递增顺序依次给出必须保留的点的编号。
输出格式
第一行包含两个正整数 、,其中 表示剩余道路的费用总和, 表示剩余道路的条数。 接下来 行,每行包含两个正整数 、,表示一条道路的两个端点。 如有多组解,输出任意一组。
8 11
1 2 6
3 1 5
2 3 8
3 4 9
3 5 10
5 4 3
5 6 9
6 4 8
6 8 8
6 7 7
8 7 10
4 2 5 7 8
42 5
2 3
3 5
5 6
6 7
6 8