| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 7 초 | 2048 MB | 3 | 3 | 3 | 100.000% |
On a small volcanic island far away from any major landmass, the Grand Council for Painless Cycling (GCPC) is facing regular complaints about the bad quality of the bike path network. Their budget is limited, but they would like to improve the situation for all the cyclists on their island. A survey helped to determine the most common destinations of the cyclists. The GCPC expects that the cyclists are satisfied with the bike path replacements if there is a way to cycle between any two destinations using only newly replaced bike paths. In order not to unduly favour any of the villages, the Council has decided that a maximum of $7$ destinations per village should be taken into account.
Figure I.1: Illustration of the second sample. Village $1$ consists of Junctions $1$, $2$, $3$, and $4$, Village $2$ consists only of junction $5$, and Village $3$ consists of the remaining junctions. Junctions that are destinations are coloured red.
There is one main cyclic bike path going around the volcano. On its way, it traverses every village on the island exactly once. Each village may have additional bike paths. How much does the GCPC have to spend at least in order to replace bike paths to connect all destinations via new paths?
The input consists of:
Additionally, the following is guaranteed:
Output the minimum cost which allows replacing bike paths such that every trip between any two destinations can be done using only newly replaced paths.
3 3 3 3 1 1 1 2 1 5 2 3 4 1 3 3 2 1 3
7
8 10 3 6 4 1 3 1 2 3 2 4 2 1 3 5 3 4 2 4 5 3 5 6 2 8 6 3 6 7 2 7 8 2 8 1 1 2 3 1 7 6 8
12