Canadian Computing Olympiad: 2020 Day 1, Problem 3
You are planning a long hiking trip through some interesting, but well-known terrain. There are
The trail system is a bit special, however. There are exactly
Additionally, it is possible to travel between any two sites using only the trails with difficulty level 1.
You would like to visit every site, starting your walk from any site of your choice and finishing at some other site, such that you visit each site at least once and the total sum of difficulty levels is minimum among all walks. Note that walking a trail
Input Specification
The first line of input contains two space-separated integers
The next
For 1 of the 25 marks available,
For an additional 2 of the 25 marks available,
For an additional 2 of the 25 marks available,
For an additional 6 of the 25 marks available,
For an additional 2 of the 25 marks available,
For an additional 3 of the 25 marks available,
For an additional 5 of the 25 marks available,
Output Specification
Output one integer, which is the minimum sum of difficulty levels taken for all trails walked to visit each site once.
Sample Input
9 10
0 1 1
0 2 1
0 3 1
1 4 1
2 5 1
2 6 1
3 7 1
3 8 1
2 4 5
6 7 3
Sample Output
11
Explanation of Output for Sample Input
This is the set of flat trails.
This is the entire set of trails with all the difficulty levels.
This is the entire set of trails, with trails with difficulty level 1 being omitted.
An optimal walk for this set of trails is
Comments