poj 3694 Network
2020-12-13 06:05
The input consists of multiple test cases. Each test case starts with a line
containing two integers N(1 ≤ N ≤ 100,000)
and M(N - 1 ≤ M ≤
200,000).
Each of the following M lines contains two
integers A and B (
1≤ A ≠ B ≤ N), which indicates a link
between computer A and B. Computers are
numbered from 1 to N. It is guaranteed that any two computers are
connected in the initial network.
The next line contains a single
integer Q ( 1 ≤ Q ≤ 1,000), which is the
number of new links the administrator plans to add to the network one by
one.
The i-th line of the following Q lines
contains two integer A and B (1
≤ A ≠ B ≤ N), which is
the i-th added new link connecting
computer A and B.
The last test case is followed by a line containing two zeros.