比赛 |
20091102 |
评测结果 |
WAWAA |
题目名称 |
复原几何图形 |
最终得分 |
60 |
用户昵称 |
Achilles |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-02 11:31:11 |
显示代码纯文本
program resume;
var
i,j,n,a,b,m,p,temp:integer;
tab,t2:array[1..50,1..50]of integer;
point,p2:array[1..50]of integer;
begin
fillchar(tab,sizeof(tab),0);
fillchar(point,sizeof(point),0);
fillchar(p2,sizeof(p2),0);
fillchar(t2,sizeof(t2),0);
assign(input,'resume.in');
assign(output,'resume.out');
reset(input);
rewrite(output);
readln(m);
while not(eof) do
begin
readln(a,b);
tab[a,b]:=1;
tab[b,a]:=1;
point[a]:=point[a]+1;
point[b]:=point[b]+1;
end;
for i:=1 to m do
begin
if (point[i]=2)and(p2[i]<2) then begin
while p2[i]<2 do
begin
for j:=1 to m do
if tab[i,j]=1 then begin
p2[i]:=p2[i]+1;
p2[j]:=p2[j]+1;
tab[i,j]:=0;
tab[j,i]:=0;
t2[i,j]:=1;
t2[j,i]:=1;
end;
end;
end;
end;
while true do
begin
p:=0;
for i:=1 to m do
if p2[i]<2 then begin
for j:=1 to m do
if (i<>j)and(p2[j]<2)and(tab[i,j]=1) then begin
p2[i]:=p2[i]+1;
p2[j]:=p2[j]+1;
t2[i,j]:=1;
t2[j,i]:=1;
p:=1;
end;
end;
if p=0 then break;
end;
write(1,' ');
fillchar(p2,sizeof(p2),0);
p2[1]:=1;
temp:=32767;
for i:=2 to m do
if t2[1,i]=1 then begin
if i<temp then temp:=i;
end;
write(temp,' ');
p2[temp]:=1;
for i:=1 to m-2 do
begin
for j:=1 to m do
begin
if (t2[temp,j]=1)and(p2[j]=0) then begin
write(j,' ');
temp:=j;
p2[j]:=1;
end;
end;
end;
close(input);
close(output);
end.