连通图
Time Limit:1000MS Memory Limit:65536K
Total Submit:141 Accepted:84
Description
判断一个图是否为一个边通图
Input
n 顶点 (n<=100)
边
Output
1 表示连通
0 表示不边通
Sample Input
5
1 2
2 3
5 4
0 0
Sample Output
0
-
var a:array[0..1000,0..1000] of longint; b:array[0..1000] of longint; n,m,i,j,k,ans,max,x,y:longint; procedure dp(dep:longint); var i:longint; begin for i:=1 to n do if b[i]=0 then if a[dep,i]=1 then begin b[i]:=1; dp(i); end; end; begin readln(n); readln(x,y); while (x<>0) or (y<>0) do begin a[x,y]:=1; a[y,x]:=1; readln(x,y); end; dp(1); for i:=1 to n do if b[i]=0 then begin write('0'); halt; end; write('1'); end.