当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6203:ping ping ping

题目描述
The structure of the computer room in Northeastern University is pretty miraculous. There are $n$ servers, some servers connect to the gateway whose IP address is 0 directly. All servers are connected with each other by $n$ netting twines. It is said that this structure is favorable for maintaining physical problem of servers.
But because of an unexpected rainstorm, the computer room was destroyed by a terrible thunderclap!
Our maintainer Bittersweet found that many servers were not able to be visited, so he hurried to the computer room to lookup the reason. After several hours, Bittersweet realized that some net gape of servers were broken by thunderclap. However, there were too many servers to find out all the broken net gapes quickly. So he came up with an idea to assess the damaged condition roughly. Bittersweet decided to turn on some servers and ping other servers randomly, then record the unsuccessful pairs of servers.
Now he need a program to analyze the record to confirm what is the $minimum$ number of servers whose net gape was destroyed by thunderclap. Can you help him to complete this work?
输入解释
There are at most 20 test cases.
In each test case, the first line is an integer $n$ ($3 \leq n \leq 10^4$), denoting the number of servers. The IP address of these servers is $1 \dots n$.
Then follows $n$ lines, each line contains two integers $u$ and $v$ ($0 \leq u, v \leq n$), denoting that the server whose IP address is $u$ is connected with the server whose IP address is $v$ by netting twine initially.
After those, there is one line contains only an integer $p$ ($p \leq 50000$), denoting the number that Bittersweet uses ping.
Then follows $p$ lines, each line contains two integers $U$ and $V$ , denoting when using server $U$ to ping server $V$, it returned unsuccessful.
输出解释
A single integer $x$ in a line, denoting at least $x$ servers whose net gape were broken.
输入样例
4
1 0
4 2
2 0
3 2
2
1 3
2 1
输出样例
1
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6203

最后修改于 2020-10-25T23:29:17+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)