比赛 |
NOIP_1 |
评测结果 |
AAAAA |
题目名称 |
画海岛地图 |
最终得分 |
100 |
用户昵称 |
Achilles |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-07-20 11:08:19 |
显示代码纯文本
program island;
var
i,j,n,t,t2,bm:integer;
arr1,arr2,last1,last2:array[0..10,0..10]of integer;
table:array[1..8,1..8]of string;
function pd(x,y,l:integer):integer;
var
i,j,num,len:integer;
begin
pd:=1;
for i:=y to y+l-1 do
begin
num:=0;
len:=0;
table[x,i]:='*';
for j:=1 to x do
begin
if table[j,i]='*' then begin
if len=0 then begin
num:=num+1;
len:=0;
end;
len:=len+1;
end
else begin
if len<>0 then begin
if arr2[i,num]<>len then pd:=0;
len:=0;
end;
end;
end;
if len<>0 then if arr2[i,num]<len then pd:=0;
table[x,i]:='';
end;
end;
procedure print;
var
i,j:integer;
begin
bm:=bm+1;
writeln(bm);
for i:=1 to n do
begin
for j:=1 to n do
if table[i,j]='*' then write('*') else write(' ');
writeln;
end;
end;
procedure draw(x,y:integer);
var
i:integer;
begin
t:=1;
for t2:=n downto 1 do
if table[x,t2]='*' then begin
t:=j+2;
break;
end;
for i:=t to last1[x,y] do
begin
if pd(x,i,arr1[x,y])=1 then begin
for j:=i to i+arr1[x,y]-1 do
begin
table[x,j]:='*';
end;
if (x=n)and(y=arr1[x,0]) then print;
if y<arr1[x,0] then draw(x,y+1) else draw(x+1,1);
for j:=i to i+arr1[x,y]-1 do
begin
table[x,j]:='';
end;
end;
end;
end;
begin
assign(input,'island.in');
assign(output,'island.out');
reset(input);
rewrite(output);
readln(n);
fillchar(arr1,sizeof(arr2),0);
fillchar(arr2,sizeof(arr2),0);
fillchar(last1,sizeof(last1),0);
fillchar(last2,sizeof(last2),0);
fillchar(table,sizeof(table),0);
for i:=1 to n do
begin
read(t);
while t<>0 do
begin
arr1[i,0]:=arr1[i,0]+1;
arr1[i,arr1[i,0]]:=t;
read(t);
end;
readln;
end;
for i:=1 to n do
begin
read(t);
while t<>0 do
begin
arr2[i,0]:=arr2[i,0]+1;
arr2[i,arr2[i,0]]:=t;
read(t);
end;
readln;
end;
for i:=1 to n do
begin
last1[i,arr1[i,0]+1]:=n+2;
for j:=arr1[i,0] downto 1 do
last1[i,j]:=last1[i,j+1]-arr1[i,j]-1;
end;
for i:=1 to n do
begin
last2[i,arr2[i,0]+1]:=n+2;
for j:=arr2[i,0] downto 1 do
last2[i,j]:=last2[i,j+1]-arr2[i,j]-1;
end;
bm:=0;
draw(1,1);
if bm=0 then writeln('no');
close(input);
close(output);
end.