#P10875. [COTS 2022] 游戏 M
[COTS 2022] 游戏 M
Background
Translated from Izborne Pripreme 2022 (Croatian IOI/CEOI Team Selection) D2T2。。
Problem Description
There is an undirected graph with nodes. We add edges to the graph one by one.
There are queries. Each query gives and asks: what is the minimum number of first edges that must be added so that there is no bridge on the connection between and (in other words, removing any single edge will not affect the connectivity between and )? In particular, if and are always disconnected, or there is always a bridge, output .
Input Format
The first line contains two integers , as described in the statement.
The next lines: the -th line contains two integers , meaning the -th edge is .
The -th line contains an integer , as described in the statement.
The next lines: each line contains two integers , describing a query.
Output Format
Output lines. Each line contains one integer, the answer to the query.
3 3
1 2
2 3
3 1
1
1 2
3
3 4
1 2
1 2
2 3
2 3
3
1 2
2 3
3 1
2
4
4
6 7
1 2
2 3
3 4
2 5
3 5
4 5
1 3
5
1 3
2 3
4 5
1 4
2 6
7
5
6
7
-1
Hint
For of the testdata, it is guaranteed that:
- , , ;
- , ;
- 。
| Subtask ID | Score | Constraints |
|---|---|---|
| , | ||
| No additional constraints. |
Translated by ChatGPT 5