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

建议使用的浏览器:

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

5876:Sparse Graph

题目描述
In graph theory, the $complement$ of a graph $ G $ is a graph $ H $ on the same vertices such that two distinct vertices of $ H $ are adjacent if and only if they are $not$ adjacent in $ G $.

Now you are given an undirected graph $ G $ of $ N $ nodes and $ M $ bidirectional edges of $unit$ length. Consider the complement of $G$, i.e., $H$. For a given vertex $ S $ on $ H $, you are required to compute the shortest distances from $ S $ to all $ N-1 $ other vertices.
输入解释
There are multiple test cases. The first line of input is an integer $T(1\le T<35) $ denoting the number of test cases. For each test case, the first line contains two integers $ N(2\le N\le 200000) $ and $ M(0\le M\le 20000) $. The following $ M $ lines each contains two distinct integers $ u, v(1\le u,v\le N) $ denoting an edge. And $ S\ (1\le S\le N) $ is given on the last line.
输出解释
For each of $ T $ test cases, print a single line consisting of $N-1 $ space separated integers, denoting shortest distances of the remaining $ N-1 $ vertices from $ S $ (if a vertex cannot be reached from S, output ``-1" (without quotes) instead) in ascending order of vertex number.
输入样例
1
2 0
1
输出样例
1
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5876

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

共提交 0

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