⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex.dpr

📁 tongji acm-online judge solution
💻 DPR
字号:
{
	Method: there exists a way to operate iff in each connected component, the number of edges is even
}
program Ural_1320(Input,Output);
const
	MaxN=1000;
type
	TIndex=Longint;
	TDisjointSet=array[1..MaxN]of TIndex;
	TComponentCount=array[1..MaxN]of TIndex;
var
	F:TDisjointSet;
	C:TComponentCount;
function Find(x:TIndex):TIndex;
begin
	if F[x]<0 then Result:=x
	else
	begin
		F[x]:=Find(F[x]);
		Result:=F[x];
	end;
end;
procedure Merge(x,y:TIndex);
begin
	x:=Find(x);
	y:=Find(y);
        if x=y then Exit;
	Inc(C[x],C[y]);
	C[y]:=0;
	F[y]:=x;
end;
procedure Main;
var
	i:TIndex;
	x,y:TIndex;
begin
	FillChar(F,SizeOf(F),255);
	FillChar(C,SizeOf(C),0);
	while not SeekEof do
	begin
		Readln(x,y);
		Merge(x,y);
		Inc(C[Find(y)]);
	end;
	for i:=1 to MaxN do
		if C[i]>0 then 
			if Odd(C[i]) then 
			begin
				Writeln(0);
				Exit;
			end;
	Writeln(1);
end;
begin
{$IFNDEF ONLINE_JUDGE}
	Assign(Input,'i.txt');
	Reset(Input);
	Assign(Output,'o.txt');
	Rewrite(Output);
{$ENDIF}
		Main;
{$IFNDEF ONLINE_JUDGE}
	Close(Input);
	Close(Output);
{$ENDIF}
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -