记录编号 |
4257 |
评测结果 |
AAAAA |
题目名称 |
画海岛地图 |
最终得分 |
100 |
用户昵称 |
bing |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.007 s |
提交时间 |
2008-10-15 21:33:21 |
内存使用 |
0.11 MiB |
显示代码纯文本
program bing;
type
daozu=array[1..8,0..8] of integer;
map=array[1..8,1..8] of integer;
limit=array[1..8,1..8] of integer;
var
f1,f2:text;
aa:map;
x,y,al:daozu;
l:limit;
n,s:integer;
procedure init;
var
i,j,k:integer;
begin
assign(f1,'island.in');reset(f1);
assign(f2,'island.out');rewrite(F2);
readln(f1,n);
for i:=1 to n do
begin
j:=0;
read(f1,k);
while k<>0 do begin inc(j);x[i,j]:=k;read(f1,k);end;
x[i,0]:=j;readln(f1);
end;
for i:=1 to n do
begin
j:=0;
read(f1,k);
while k<>0 do begin inc(j);y[i,j]:=k;read(f1,k);end;
y[i,0]:=j;readln(f1);
end;
fillchar(l,sizeof(l),0);fillchar(aa,sizeof(aa),0);
fillchar(al,sizeof(al),0);
for i:=1 to n do
begin
k:=n;
for j:=x[i,0] downto 1 do begin l[i,j]:=k-x[i,j]+1;k:=l[i,j]-2;end;
end;
close(f1);
s:=0;
end;
function pd(a,b,c:integer;var ans:map;var ansl:daozu):boolean;
var
i,j,k:integer;
temp1:map;temp2:daozu;
begin
pd:=true;
if a=1 then
for i:=b to b+x[a,c]-1 do
begin inc(ans[a,i]);inc(ansl[i,0]);inc(ansl[i,1]);end
else begin
temp1:=ans;temp2:=ansl;
for i:=b to b+x[a,c]-1 do begin
inc(ans[a,i]);
if ans[a-1,i]=0 then inc(ansl[i,0]);
j:=ansl[i,0];
if j>y[i,0] then begin pd:=false;ans:=temp1;ansl:=temp2;exit;end;
inc(ansl[i,j]);
if ansl[i,j]>y[i,j] then begin pd:=false;ans:=temp1;ansl:=temp2;exit;end;
end;
end;
end;
procedure put(ans:map);
var
i,j:integer;
begin
inc(s);
writeln(f2,s);
for i:=1 to n do
begin
for j:=1 to n do
if ans[i,j]=0 then write(f2,' ')
else
if ans[i,j]=1 then write(f2,'*');
writeln(f2);
end;
end;
procedure nb(a,b,c:integer;ans:map;ansl:daozu);
var
i,j,k,m:integer;
temp1:map;temp2:daozu;
begin
for i:=b to l[a,c] do
begin
temp1:=ans;temp2:=ansl;
if pd(a,i,c,temp1,temp2) then
begin
j:=a;k:=i+x[a,c]+1;m:=c+1;
if m>x[a,0] then begin inc(j);k:=1;m:=1;end;
if j>n then put(temp1)
else nb(j,k,m,temp1,temp2);
end;
end;
end;
begin
init;
nb(1,1,1,aa,al);
if s=0 then write(f2,'no');
close(f2);
end.