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

建议使用的浏览器:

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

3697:USTC campus network

题目描述

USTC campus network is a huge network. There is a bi-directional link between every pair of computers in the network. One of the computers is the BBS server, which is so popular that thousands of people log on it every day. Recently some links of the network are damaged by the rainstorm. The network administrator is going to check which computers are still connected with the BBS server directly or indirectly.

You are to help the administrator to report the number of computers still connecting with the BBS server (not including itself).

输入解释

The input consists of multiple test cases. Each test case starts with a line containing two integers N and M (1 ≤ N ≤ 10,000, 0 ≤ M ≤ 1,000,000), which are the number of computers and the number of damaged links in USTC campus network, respectively. The computers are numbered from 1 to N and computer 1 is the BBS server.
Each of the following M lines contains two integers A and B(1 ≤ AN, 1 ≤ BN, AB), which means the link between computer A and B is damaged. A link will appear at most once.

The last test case is followed by a line containing two zeros.

输出解释

For each test case, print a line containing the test case number( beginning with 1) followed by the number of computers still connecting with the BBS server.

输入样例
3 2
1 2
1 3
4 3
1 2
3 2
4 2
0 0
输出样例
Case 1: 0
Case 2: 2

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3697

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

共提交 0

通过率 --%
时间上限 内存上限
4000 65536