#P1944A. Destroying Bridges
Destroying Bridges
Destroying Bridges
题面翻译
有 个岛屿,编号为 。最初,每对岛屿都由一座桥连接。因此,一共有 座桥。
Everule 住在 岛上,喜欢利用桥梁访问其他岛屿。Dominater 有能力摧毁最多 座桥梁,以尽量减少 Everule 可以使用(可能是多座)桥梁到达的岛屿数量。
如果 Dominater 以最佳方式摧毁桥梁,求 Everule 可以访问的岛屿(包括岛屿 )的最少数量。
题目描述
There are islands, numbered . Initially, every pair of islands is connected by a bridge. Hence, there are a total of bridges.
Everule lives on island and enjoys visiting the other islands using bridges. Dominater has the power to destroy at most bridges to minimize the number of islands that Everule can reach using (possibly multiple) bridges.
Find the minimum number of islands (including island ) that Everule can visit if Dominater destroys bridges optimally.
输入格式
Each test contains multiple test cases. The first line contains a single integer ( ) — the number of test cases. The description of the test cases follows.
The first and only line of each test case contains two integers and ( , ).
输出格式
For each test case, output the minimum number of islands that Everule can visit if Dominater destroys bridges optimally.
样例 #1
样例输入 #1
6
2 0
2 1
4 1
5 10
5 3
4 4
样例输出 #1
2
1
4
1
5
1
提示
In the first test case, since no bridges can be destroyed, all the islands will be reachable.
In the second test case, you can destroy the bridge between islands and . Everule will not be able to visit island but can still visit island . Therefore, the total number of islands that Everule can visit is .
In the third test case, Everule always has a way of reaching all islands despite what Dominater does. For example, if Dominater destroyed the bridge between islands and , Everule can still visit island by traveling by as the bridges between and , and between and are not destroyed.
In the fourth test case, you can destroy all bridges since . Everule will be only able to visit island (island ).