记录编号 |
1734 |
评测结果 |
AAAAW |
题目名称 |
画海岛地图 |
最终得分 |
80 |
用户昵称 |
francis |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.031 s |
提交时间 |
2008-09-07 13:10:00 |
内存使用 |
0.11 MiB |
显示代码纯文本
program island;
const
fin='island.in';
fou='island.out';
var
h:array[1..8,1..8]of longint;
n1:array[1..8]of longint;
l:array[1..8,1..8]of longint;
n2:array[1..8]of longint;
s:array[1..8,1..8]of char;
last:array[1..8,1..8]of longint;
b:array[1..8,1..8]of boolean;
number,k,x,y,st,n,i,j:longint;
bo:boolean;
f1,f2:text;
procedure init;
begin
assign(f1,fin); assign(f2,fou); reset(f1); rewrite(f2);
read(f1,n);
for i:= 1 to n do
repeat
read(f1,x);
if x<>0 then begin
inc(n1[i]);
h[i,n1[i]]:=x;
end;
until x=0;
for i:=1 to n do
repeat
read(f1,x);
if x<>0 then begin
inc(n2[i]);
l[i,n2[i]]:=x;
end;
until x=0;
for i:=1 to 8 do
for j:=1 to n1[i] do
begin
last[i,j]:=n+2;
for k:=j to n1[i] do
last[i,j]:=last[i,j]-(h[i,k]+1);
end;
end;
procedure pan(x,y:longint);
var
all,total,t:longint;
begin
total:=0;
for t:=x-1 downto 1 do
if b[t,y]=true then inc(total);
t:=1; all:=l[y,1];
while (all<total)and(t<=n2[y]) do
begin inc(t); all:=all+l[y,t]; end;
if (all=total)and(b[x-1,y]=true) then bo:=false;
if (t=n2[y])and(all=total) then bo:=false;
end;
procedure print;
begin
inc(number);
writeln(f2,number);
for i:=1 to n do
begin
for j:=1 to n do
if b[i,j]=true then write(f2,'*') else write(f2,' ');
writeln(f2);
end;
end;
procedure search(x,y,st:longint);
var
k,p:longint;
begin
for k:=st to last[x,y] do
begin
bo:=true;
for p:=1 to h[x,y] do
pan(x,k+p-1);
if bo=true then
begin
for p:=1 to h[x,y] do
b[x,k+p-1]:=true;
if (x=n)and(y=n1[x]) then print
else begin
if y=n1[x] then search(x+1,1,1);
if y<n1[x] then search(x,y+1,k+h[x,y]+1);
end;
for p:=1 to h[x,y] do
b[x,k+p-1]:=false;
end;
end;
end;
begin
init;
search(1,1,1);
if number=0 then write(f2,'no');
close(f1); close(f2);
end.