#P14857. [ICPC 2021 Yokohama R] Planning Railroad Discontinuation
[ICPC 2021 Yokohama R] Planning Railroad Discontinuation
题目描述
The ICPC Kingdom has a large round lake in its center, and all of its cities are developed around the lake, forming a circle of cities. Because all of them are developed under the same urban plan, the cities are made quite similar. They have exactly the same subway networks. Some of their stations are also stations of inter-city bullet trains connecting two corresponding stations of adjacent cities. All of the train routes provide two-way traffic between two terminal stations without any intermediate stations.
The cities have the same number of subway stations and subway routes. In each city, the stations are numbered sequentially as . Whether two stations in a city are connected by a subway route depends only on their station numbers and not on the city. If a station is connected to a station in one city, so is in all the other cities. The travel distance between two stations and are the same for all the cities.
All the cities have exactly the same list of station numbers of bullet train stations. If a station is a bullet train station in one city, so is in all the other cities. All the pairs of two bullet train stations of the same station number in two adjacent cities are connected by a bullet train route. If a station is one end of a bullet train route, the station in an adjacent city is the other end. There exist no other bullet train routes. One can travel between any two stations in the Kingdom via one or more subway and/or bullet train services.
Due to financial difficulties in recent years, the Kingdom plans to discontinue some of the subway and bullet train services to reduce the maintenance cost of the railroad system. The maintenance cost is the sum of maintenance costs of the subway routes and the bullet train routes. The maintenance cost of a subway route is the sum of base cost depending on the city and cost proportional to the travel distance of the route. The maintenance cost of a bullet train route depends only on the two cities connected by the route.
You are asked to make a plan to discontinue some of the routes that minimizes the total maintenance cost. Of course, all the pairs of the stations in the Kingdom should still be connected through one or more subway and/or bullet train services after the discontinuation.
输入格式
The input consists of a single test case of the following format.
$$\begin{aligned} &n\ m \\ &v_1\ u_1\ d_1 \\ &\vdots \\ &v_m\ u_m\ d_m \\ &l \\ &a_0\ b_0 \\ &\vdots \\ &a_{l-1}\ b_{l-1} \\ &r \\ &s_1 \\ &\vdots \\ &s_r \end{aligned}$$Here, is an integer satisfying , which is the number of the subway stations in a city. The stations in each city are numbered from to . is an integer satisfying , which is the number of the subway routes in a city. The following lines are information on the subway system in a city. The -th of the lines has three integers , , and , satisfying , , , and . They mean that a subway route connects stations numbered and , and its maintenance cost proportional to the travel distance is . There is at most one subway route between two stations. All the subway stations in a city are connected directly or indirectly via one or more subway routes.
in the next line is an integer satisfying , which is the number of cities in the Kingdom. The cities are numbered from to , and the city is also called the city . For each , the cities and are adjacent. and in the following lines are integers satisfying and . is the maintenance cost of a bullet train route connecting the cities and . is the base cost of the subway routes in the city .
is an integer satisfying , which is the number of the bullet train stations in each city. are the station numbers of the bullet train stations in each city.
输出格式
Output in a single line the integer representing the minimum maintenance cost of the railroad system after the discontinuation that minimizes the cost while keeping all the stations connected, directly or indirectly.
2 1
0 1 3
3
6 1
4 2
5 3
1
1
24
3 3
0 1 7
1 2 8
2 0 5
4
8 1
5 1
9 3
7 3
2
1
2
76
5 8
0 1 1
2 1 2
4 0 5
3 4 7
3 2 8
0 2 4
4 1 3
2 4 6
6
3 2
9 3
7 1
5 3
3 2
5 2
4
0
2
3
4
120