ac1320.pas
来自「Ural(Acm.timus.ru)题解 By Maigo大牛」· PAS 代码 · 共 43 行
PAS
43 行
program ural1320;
const
n=1000;
var
root:array[1..n]of word;
edges:array[1..n]of longint;
i,j:word;
procedure pathcomp(x:word);
var
r,t:word;
begin
r:=x;
while root[r]<>r do
r:=root[r];
repeat
t:=root[x];
root[x]:=r;
x:=t;
until root[x]=r;
end;
begin
for i:=1 to n do
root[i]:=i;
while not seekeof do begin
read(i,j);
pathcomp(i);
pathcomp(j);
if root[i]<>root[j] then begin
inc(edges[root[j]],edges[root[i]]);
root[root[i]]:=root[j];
end;
inc(edges[root[j]]);
end;
for i:=1 to n do
if (root[i]=i) and odd(edges[i]) then begin
writeln(0);
halt;
end;
writeln(1);
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?