시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 39 | 24 | 20 | 74.074% |
There are N cities in JOI Kingdom, which are indexed by the numbers from 1 to N. City 1 is the capital city. Each city has a value called liveliness and the initial value of liveliness of city i (1 ≤ i ≤ N) is Ci.
Road in JOI Kingdom connects two different cities bidirectionally. Initially, there is no road in JOI Kingdom. You have planned N − 1 constructions of roads. The j-th construction (1 ≤ j ≤ N − 1) is planned to be done in the follwing way.
You want to know the cost of each construction.
Given the data of cities and constructions of roads, write a program which calculates the cost of each construction.
Read the following data from the standard input.
Write N − 1 lines to the standard output. The j-th line (1 ≤ j ≤ N − 1) of output contains the cost of the j-th construction of road.
번호 | 배점 | 제한 |
---|---|---|
1 | 7 | N ≤ 500. |
2 | 9 | N ≤ 4000. |
3 | 84 | There are no additional constraints. |
5 1 2 3 4 5 1 2 2 3 2 4 3 5
0 0 0 2
In Sample Input 1, constructions are done as follows:
10 1 7 3 4 8 6 2 9 10 5 1 2 1 3 2 4 3 5 2 6 3 7 4 8 5 9 6 10
0 0 0 1 1 0 1 2 3