#P3242. [HNOI2015] 接水果
[HNOI2015] 接水果
Description
Kazami Yuuka really enjoys playing a game called osu!, and her favorite mode is catching fruits. Since she has already DT FC’d The Big Black, she thinks the game is too easy, so she invented a harder version.
First, there is a map that is a tree with vertices and edges.
There are plates on this tree. Each plate is actually a path, and each plate also has a weight. The -th plate is the path from vertex to vertex (since it is a tree, the path from to is unique), with weight .
Next, fruits will fall one by one; each fruit is essentially also a path. The -th fruit is the path from vertex to vertex .
Each time, Yuuka needs to choose one plate to catch the current fruit: a plate can catch a fruit if and only if the plate’s path is a subpath of the fruit’s path. By convention, the path from to is considered the same as the path from to .
To increase the difficulty, for the -th fruit, among all plates that can catch it, you must choose the one with the -th smallest weight. Each plate can be reused without limit: after catching one fruit, it can continue to catch other fruits as long as it is a subpath of the fruit’s path. Yuuka thinks this game is hard; can you solve it easily for her?
Input Format
- The first line contains three integers , , and , denoting the size of the tree, the number of plates, and the number of fruits.
- The next lines each contain two integers and , indicating that there is an edge between and in the tree. The vertices are labeled from to .
- The next lines each contain three integers , , and , describing a plate whose path is from to with weight , where .
- The next lines each contain three integers , , and , describing a fruit whose path is from to , where . You need to choose the -th smallest plate, and the -th smallest is guaranteed to exist.
Output Format
For each fruit, output one line containing the weight of the chosen plate.
10 10 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
3 2 217394434
10 7 13022269
6 7 283254485
6 8 333042360
4 6 442139372
8 3 225045590
10 4 922205209
10 8 808296330
9 2 486331361
4 9 551176338
1 8 5
3 8 3
3 8 4
1 8 3
4 8 1
2 3 1
2 3 1
2 3 1
2 4 1
1 4 1
442139372
333042360
442139372
283254485
283254485
217394434
217394434
217394434
217394434
217394434
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号