Canadian Computing Competition: 2025 Stage 1, Senior #4
You're trapped in a scorching dungeon with
To help you navigate the lavatic tunnels, you are wearing a pair of heat-resistant boots that initially have a chilling level of
Luckily, when you're standing in a room, you can increase or decrease the chilling level of your boots by
Input Specification
The first line of input contains two integers
The next
There is at most one tunnel connecting any pair of rooms, and it is possible to reach all other rooms from room
The following table shows how the available
Marks | Additional constraints |
---|---|
2 | |
4 | For all tunnels, |
4 | Each room has at most |
5 | None |
Output Specification
Output the minimum cost (in coins) to reach room
Sample Input
5 7
1 2 3
2 3 2
1 3 6
3 4 3
4 5 7
2 4 1
2 5 10
Sample Output
9
Explanation for Sample Output
A diagram of the dungeon is shown above. The optimal escape strategy is as follows:
- Increase the chilling level to
for a cost of coins. - Walk through the tunnel to room
. - Decrease the chilling level to
for a cost of coin. - Walk through the tunnel to room
. - Increase the chilling level to
for a cost of coin. - Walk through the tunnel to room
. - Increase the chilling level to
for a cost of coins. - Walk through the tunnel to room
and escape.
This has a total cost of
Comments