100 atcoder#ABC051D. [ABC051D] Candidates of No Shortest Paths
[ABC051D] Candidates of No Shortest Paths
Score : points
Problem Statement
You are given an undirected connected weighted graph with vertices and edges that contains neither self-loops nor double edges. The -th edge connects vertex and vertex with a distance of . Here, a self-loop is an edge where , and double edges are two edges where or $(a_i,b_i)=(b_j,a_j) (1 \leq i. A connected graph is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
Constraints
- is an integer.
- The given graph contains neither self-loops nor double edges.
- The given graph is connected.
Input
The input is given from Standard Input in the following format:
Output
Print the number of the edges in the graph that are not contained in any shortest path between any pair of different vertices.
3 3
1 2 1
1 3 1
2 3 3
1
In the given graph, the shortest paths between all pairs of different vertices are as follows:
- The shortest path from vertex to vertex is: vertex → vertex , with the length of .
- The shortest path from vertex to vertex is: vertex → vertex , with the length of .
- The shortest path from vertex to vertex is: vertex → vertex , with the length of .
- The shortest path from vertex to vertex is: vertex → vertex → vertex , with the length of .
- The shortest path from vertex to vertex is: vertex → vertex , with the length of .
- The shortest path from vertex to vertex is: vertex → vertex → vertex , with the length of .
Thus, the only edge that is not contained in any shortest path, is the edge of length connecting vertex and vertex , hence the output should be .
3 2
1 2 1
2 3 1
0
Every edge is contained in some shortest path between some pair of different vertices.