| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 35 | 25 | 22 | 70.968% |
You have crashed your spaceship into a swampy planet. Luckily, you were rescued by a small 900-year-old green alien who lives at the base of a massive tree. Around the tree are many trails which lead to other alien's houses.
The green alien says he will repair your spaceship if you will help him with a very strange task. "Lots of mist, we have. Hard to see, it is. Help me light up my trails, you will," the alien says.
The green alien hands you a map of the trail system. There are $n$ houses, each labeled with a unique number between 1ドル$ and $n,ドル inclusive. There are $m$ trails, each of which goes between a pair of alien's houses. Each trail is labeled with a unique number between 1ドル$ and $m,ドル inclusive. The green alien has also marked the length of each of the $m$ trails.
The green alien shows you a reel of wire and a box of light-bulbs. "Be able to visit everyone else on lighted trails, everyone should. Minimum amount of wire and lights, you should use."
The green alien speaks quite strangely, so it takes a while for you to process this request. Then you realize that the alien wants you to light up the minimum length of trails so that every alien can visit every other alien by travelling only on lighted trails.
Your task is to determine which trails to light up.
The first line contains two integers $n$ and $m$ (in that order).
The subsequent $m$ lines specify information about the $m$ trails labeled on the map, in sorted order (that is, information about trail 1ドル$ is on the first line, trail 2ドル$ on the second line, etc.). Each of the lines contain three integers, $h_1,ドル $h_2,ドル and $d$ (in that order). $h_1$ and $h_2$ specify the house numbers of the houses on opposite ends of the trail, and $d$ specifies the trail's distance.
The first line of the output should contain $k,ドル the number of trails which you need to light up.
The subsequent $k$ lines should contain the numbers corresponding to the trail labels which you need to light up.
3 3 1 2 1 3 1 2 2 3 1
2 1 3
8 10 8 4 2 1 7 2 4 3 8 1 2 4 2 3 8 3 6 2 2 6 5 6 5 7 8 1 7 7 3 7
7 6 2 7 9 1 4 8
School > CS@Mines > CS@Mines HSPC 2019 G번