#FW0000070. Loại bỏ cạnh dư (Edge Deletion)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Loại bỏ cạnh dư (Edge Deletion)
Edge Deletion
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given a positively weighted undirected graph, count the edges whose individual deletion does not change any all-pairs shortest distance. A replacement path of equal length is sufficient.
Input
First , followed by undirected weighted roads using 1-based vertices. Parallel roads may occur and are treated as separate edges.
Output
Print the number of individually removable edges.
Subtasks
-
Subtask 1 (40 points): . , ; mỗi cạnh có chỉ số riêng, cho phép cạnh song song.
-
Subtask 2 (60 points): . , ; mỗi cạnh có chỉ số riêng, cho phép cạnh song song.
Examples
Input
3 3
1 2 2
2 3 3
1 3 5
Output
1
Explanation
The direct edge 1–3 of weight 5 can be replaced by the two-edge path of weight 2+3=5. Removing this edge preserves every distance.