PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000069. Cạnh không thuộc đường ngắn nhất (Candidates of No Shortest Paths)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Cạnh không thuộc đường ngắn nhất (Candidates of No Shortest Paths)
Candidates of No Shortest Paths
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given an undirected graph with positive edge weights, count edges that do not belong to any shortest path between any pair of vertices. Each input edge is counted separately.
Input
First , followed by undirected edges using 1-based vertices. Parallel edges are allowed; self-loops are not.
Output
Print the number of edges absent from every shortest path.
Subtasks
-
Subtask 1 (40 points): . , ; đường vô hướng, cho phép cạnh song song.
-
Subtask 2 (60 points): . , ; đường vô hướng, cho phép cạnh song song.
Examples
Input
3 3
1 2 1
2 3 1
1 3 4
Output
1
Explanation
Edge 1–3 weighs 4 while path 1–2–3 costs only 2. Therefore exactly one edge is absent from all shortest paths.