100 atcoder#ABC160D. [ABC160D] Line++
[ABC160D] Line++
Score : points
Problem Statement
We have an undirected graph with vertices numbered to and edges as follows:
- For each , there is an edge between Vertex and Vertex .
- There is an edge between Vertex and Vertex .
For each , solve the problem below:
- Find the number of pairs of integers such that the shortest distance between Vertex and Vertex in is .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
For each in this order, print a line containing the answer to the problem.
5 2 4
5
4
1
0
The graph in this input is as follows:
There are five pairs such that the shortest distance between Vertex and Vertex is : .
There are four pairs such that the shortest distance between Vertex and Vertex is : .
There is one pair such that the shortest distance between Vertex and Vertex is : .
There are no pairs such that the shortest distance between Vertex and Vertex is .
3 1 3
3
0
The graph in this input is as follows:
7 3 7
7
8
4
2
0
0
10 4 8
10
12
10
8
4
1
0
0
0