#P16918. [JLCPC 2026] 图
[JLCPC 2026] 图
Problem Description
Given a simple, undirected, connected graph with vertices and edges. You need to choose two different edges to delete, obtaining a new graph , and must remain connected.
Let the two deleted edges be and . You need to minimize the sum of the shortest path length from to in and the shortest path length from to in . Output this minimum value, and also compute how many unordered edge-deletion plans can achieve this minimum.
Input Format
The first line contains an integer (), the number of test cases. Then follow blocks, each describing one test case. For each test case:
- The first line contains two integers (, ).
- The next lines each contain two integers , representing an edge.
The constraints guarantee that . The given graph has no multiple edges and no self-loops, and there exists at least one way to delete edges such that the graph remains connected.
Output Format
For each test case, output one line containing two integers: the minimum value, and the number of unordered edge-deletion plans that achieve this minimum.
4
4 6
1 2
1 3
1 4
2 3
2 4
3 4
4 5
1 2
2 3
3 4
1 4
1 3
5 6
1 3
2 3
1 4
2 4
1 5
2 5
5 7
1 2
2 3
3 4
4 5
1 5
2 5
1 4
4 15
4 4
6 12
4 4
Hint
Translated by ChatGPT 5