COCI '22 Contest 3 #3 Baltazar

View as PDF

Points: 17 (partial)
Time limit: 4.0s
Memory limit: 512M

Problem types

Baltazar decided to go on a vacation. Currently, he is in Baltazargrad, and wants to travel to Primošten. To get there, he has to go through many cities. There are cities, and they are connected with two-way roads. Baltazargrad is labelled as city no. , and Primošten as city no. .

Baltazar isn't sure about the route from Baltazargrad to Primošten, so he will use GPS. It will lead him to his destination using the shortest route.

But Baltazar really likes to travel, and he can pour his magic potion on any road (even the ones he won't pass by), and increase its length by kilometres. He can pour it on only one road.

Soon he realized that he had to check-in in at the hotel Zora in Primošten before noon, so he couldn't increase the length of the shortest route too much. Now, he wants to know how many roads he can pour his magic potion on so that the shortest distance between Baltazargrad and Primošten increases by exactly kilometre.

Help him determine the roads he can pour his magic potion on.

Input Specification

Each test contains multiple test cases. The first line contains the number of test cases . The description of the test cases follows.

The first line of each test case contains integers and , the number of cities, and the number of roads between cities.

The following lines contain integers , , , meaning there is a road between cities and , and its length is . Between each pair of cities, there is at most one road connecting them.

All the cities are connected, i.e., for each pair of cities, there is a path from one to another, but not necessary direct.

It is guaranteed that the sum of over all test cases does not exceed , and that the sum of over all test cases does not exceed .

Output Specification

In the first line, print the integer , the number of roads on which Baltazar can pour his magic potion. In the second line, print integers, the indices of the roads in increasing order.

Constraints

There is a road between Baltazargrad and Primošten, and its length is kilometre longer than the shortest distance between these cities.

3
6 6
1 2 2
1 3 2
2 4 2
3 5 2
4 5 1
5 6 2
6 6
1 2 2
1 3 2
2 4 2
3 5 2
4 5 3
5 6 2
6 7
1 2 2
1 3 2
2 4 2
3 5 2
4 5 1
5 6 2
1 6 7

2
2 4
0
3
2 4 6

Explanation for Sample

The cities and the roads are shown in the image. If Baltazar pours his magic potion on road (between cities and ), or on road (between cities and ), then the shortest distance between cities and will increase by .