#P3906. Geodetic集合
Geodetic集合
Description
A graph is an undirected connected graph with no self-loops, and there is at most one edge between any two vertices. We define the shortest path between vertices and as a path from to that uses the fewest edges. Every vertex that lies on some shortest - path is called a - Geodetic vertex, and the set of these vertices is denoted by .
We call the set a Geodetic set.
For example, in the figure below, , , and .

Given a graph and several pairs , please compute for each pair.
Input Format
The first line contains two integers , representing the number of vertices and edges of (vertices are numbered ).
The next lines each contain two integers , indicating that there is an undirected edge between vertices and .
The -th line contains an integer , representing the number of given pairs.
The next lines each contain two integers , the start and end vertices of each pair.
Output Format
Output lines. For each pair in the input, output in one line all vertex indices in in increasing order of vertex indices.
5 6
1 2
1 3
2 3
2 4
3 5
4 5
3
2 5
5 1
2 4
2 3 4 5
1 3 5
2 4
Hint
For all testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号