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

建议使用的浏览器:

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

4677:Query on Graph

题目描述
Given an undirected and connected graph with n vertices and m edges, and q queries on the graph. In each query, you are given two integers l, r, and output the number of connected components of the graph only with vertices labelled from l to r (that means deleting the vertices labelled 1, 2, ..., l-1, r+1, r+2, ... , n and the corresponding edges from the graph, then output the number of connected components).
输入解释
The first line of the input contains an integer T (T<=10), indicating the number of test cases.
For each test case, the first line contains two integers n, m (1<=n<=30000, n-1<=m<=3*n), as described above.
For next m lines, each line contains two integers u, v (1<=u, v<=n), indicates there is an edge between vertex u and vertex v.
Next line is an integer q(1<=q<=30000), indicates the number of queries.
For next q lines, each line contains two integers l, r (1<=l<=r<=n), indicates the query.
The graph are generated randomly and there are only few big datas.
输出解释
For each test case, output "Case #X:" first, X is the test number. Then output q lines, each with a number, the answer to each query.
输入样例
1
9 10
1 2
1 3
2 4
2 5
4 5
3 6
3 7
6 9
8 9
8 7
4
1 2
3 5
6 9
6 7
输出样例
Case #1:
1
2
1
2
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

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

源链接: HDU-4677

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

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 131072/65536K(Java/Others)