比赛 |
20091102 |
评测结果 |
WAWWW |
题目名称 |
复原几何图形 |
最终得分 |
20 |
用户昵称 |
EnAsn |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-02 11:33:29 |
显示代码纯文本
program ex;
type
ss=array[0..50]of integer;
zs=array[0..50]of boolean;
sz=array[0..50,0..50]of boolean;
var
map:sz;
ans:ss;
flag:zs;
n:integer;
procedure init;
var
x,y,i:integer;
begin
assign(input,'resume.in');
assign(output,'resume.out');
reset(input);
rewrite(output);
readln(n);
while not eof do
begin
readln(x,y);
map[x,y]:=true;
map[y,x]:=true;
end;
close(input);
for i:=1 to n do
begin
map[0,i]:=true;
map[i,0]:=true;
end;
for i:=1 to n do flag[i]:=true;
end;
function pd:boolean;
var
i,j,k:integer;
a:array[0..50,0..2]of integer;
begin
pd:=true;
fillchar(a,sizeof(a),0);
for i:=1 to n-1 do
for j:=i+1 to n do
if map[i,j] then
begin
for k:=1 to a[0,0] do
begin
if (ans[i]>a[k,1])and(ans[i]<a[k,2])and(ans[j]>a[k,2]) then exit(false);
if (ans[j]>a[k,1])and(ans[j]<a[k,2])and(ans[i]<a[k,1]) then exit(false);
end;
inc(a[0,0]);
a[a[0,0],1]:=ans[i];
a[a[0,0],2]:=ans[j];
end;
end;
procedure print;
var
i:integer;
begin
for i:=1 to n-1 do write(ans[i],' ');
writeln(ans[n]);
close(output);
end;
procedure dota(step:integer);
var
i,j:integer;
begin
if step-1=n then
if pd then
begin
print;
halt;
end;
for i:=1 to n do
if flag[i] then
if map[ans[step-1],i] then
begin
ans[step]:=i;
flag[i]:=false;
dota(step+1);
ans[step]:=0;
flag[i]:=true;
end;
end;
begin
init;
dota(1);
end.