Problem Description
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
Input
T(1≤T<35) denoting the number of test cases. For each test case, the first line contains two integers N(2≤N≤200000) and M(0≤M≤20000). The following M lines each contains two distinct integers u,v(1≤u,v≤N) denoting an edge. And S (1≤S≤N)
Output
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
Sample Input
1 2 0 1
Sample Output
1
求最短路,由于是完全图上删边,显然最短路不会太长,所以暴力的扫描即可。