[6.12] school test T3-city transportation

Or I go to write it T2 (escape

First title came out:

[Problem Description] There are n cities, numbered 1 ~ n. Which i number of bustling city of pi. Province highway and m both directions counterparts numbered 1 ~ m. No. j motorway connections numbered aj and bj two cities, after the cost of the highway is wj. If the city from a city x to y, in addition to paying for highway tolls to pay an "urban construction fee" (for all urban cities from x to y in the bustling city through which the maximum degree, including x and y Inside).

Now the q proposed inquiry, asking each given a set of x and y, you need to answer the city from x to y, the required minimum transportation costs (costs + city highway construction costs) is.

[Enter]

The first row of three integers n, m, q. The second row of n integer representing p1 ~ pn.

Subsequently m rows, each row three positive integer, j-th row comprising Aj, Bj, Wj.

Then Q line of each two positive integers x, y represents a set of query.

[Output]

A total of Q lines, is the answer to question Q: x Urban transportation costs to a minimum y city.

[Sample input]

5 7 2

2 5 3 3 4

1 2 3

1 3 2

2 5 3

5 3 1

5 4 1

2 4 3

3 4 4

1 4

2 3

[Sample output]

8 9

[Agreement] and the range of data

n≤250, m≤20000, Q≤10000, Pi≤10000, Wj≤2000, to ensure that any two cities can reach each other.

[Description] sample diagrams, grid represents the city's first number is the city number, the second number is the red of the bustling city.

(1) from the minimum cost route traffic to an urban city is 4: 1354; highways fee is 1 + 2 + 1 = 4; urban construction fee is max {2,3,4,3} = 4; Total transportation costs 4 + 4 = 8.

(2) minimum cost of transportation route from city to city 2 is 3: 253; road tolls is 3 + 1 = 4; urban construction fee is max {5,4,3} = 5; 4 + 5 Total transportation costs = 9.


 

(Run away

 

Guess you like

Origin www.cnblogs.com/zhuier-xquan/p/11010091.html