P27168 [AtCoder] Too Enjoyable Home Gardening
提高
题目描述

Problem Description

※Kitamu is the name of the person who helped create this problem. Also, Kitamu's girlfriend is not Iroha-chan.

Kitamu's hobby is home gardening. Kitamu has $ N $ pots, each pot is numbered from $ 1 $ to $ N $. There are also $ M $ waterways connecting the pots, where waterway $ i $ connects pot $ A_i $ and pot $ B_i $. Waterway $ i $ can transfer $ C_i $ deciliters of water per second in both directions. It is guaranteed that from any pot, you can reach any other pot via some waterways.

Now, Kitamu's relationship with his girlfriend is progressing smoothly, and she is going to visit his house. To show his domestic side, Kitamu has been taking extra care of his plants.

However!

He realized that he added too many waterways to improve water flow, making the setup very unsightly. He fears that this might make him look disorganized. Therefore, he decided to remove some waterways to minimize the number of waterways while keeping the following points in mind:

  • Ensure that from any pot, you can still reach any other pot via some waterways.
  • Maximize the total amount of water that can be transferred through the remaining waterways.

You are curious about which waterways Kitamu kept, so you decided to calculate it programmatically.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ A_1 $ $ B_1 $ $ C_1 $ $ A_2 $ $ B_2 $ $ C_2 $ $\vdots$ $ A_M $ $ B_M $ $ C_M $

Output Format

Output the indices of the waterways that Kitamu kept in ascending order, each on a new line.

It can be proven that under the constraints of this problem, there is always exactly one answer. (Added on 2019/05/01 13:25)

Sample Input and Output

Sample Input #1

5 10
4 1 45
4 2 48
5 3 72
1 4 93
5 1 32
1 3 56
5 1 38
5 4 41
5 2 6
5 1 19

Sample Output #1

2
3
4
6

Sample Input #2

5 8
1 4 72
2 1 52
1 3 10
5 3 7
3 4 37
3 2 47
4 1 82
5 3 57

Sample Output #2

2
6
7
8

Notes/Hints

Constraints

  • All inputs are integers.
  • $2 \leq N \leq 2 \times 10^5$
  • $1 \leq M \leq 4 \times 10^5$
  • $1 \leq A_i, B_i \leq N$ $(1 \leq i \leq M)$
  • $A_i \neq B_i$ $(1 \leq i \leq M)$
  • $1 \leq C_i \leq 10^9$ $(1 \leq i \leq M)$
  • $C_i \neq C_j$ $(1 \leq i, j \leq M$ and $i \neq j)$

Explanation

Explanation

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 10 4 1 45 4 2 48 5 3 72 1 4 93 5 1 32 1 3 56 5 1 38 5 4 41 5 2 6 5 1 19
样例输出
2 3 4 6