EISMLEDG - Question 2

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
Hà Minh Ngọc
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

You are given an undirected graph that has ~n~ vertices and ~m~ edges. You should output the list of edges in lexicographic order. Note that if there is more than one edge between two vertices, you should output the smallest weight edge only.

Input

  • The first line contains two integers ~n, m~ ~(0 < n, m ≤ 10^5)~.
  • Each of the next ~m~ lines contains three integers ~a, b, c~ representing an edge that connects vertex ~a~ and vertex ~b~ and has weight ~c~ ~(0 ≤ a, b < n , 0 < c < 10^9)~.

Output

  • The required list of edges.

Sample Input

5 6
0 1 1
1 2 2
2 3 5
0 3 3
2 1 1
3 0 1

Sample Output

0 1 1
0 3 1
1 2 1
2 3 5

Notes


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.