记录编号 |
2070 |
评测结果 |
AAAAA |
题目名称 |
画海岛地图 |
最终得分 |
100 |
用户昵称 |
thegy |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.002 s |
提交时间 |
2008-09-11 22:47:35 |
内存使用 |
0.11 MiB |
显示代码纯文本
program island;
var
line,column:array[1..8,0..9]of longint;
last:array[1..8,1..9]of longint;
g:array[0..8,1..8]of char;
n,i,j,ans:longint;
fin,fout:text;
function can(a,b,c:longint):boolean;
var
ii,jj,s,v:longint;
begin
for ii:=b to b+c-1 do
begin
s:=0; v:=0;
for jj:=1 to a do
begin
if (g[jj,ii]='*') and (g[jj-1,ii]=' ') then
begin
inc(s); v:=1;
end else begin
if (g[jj,ii]='*') then inc(v);
end;
end;
if (v>column[ii,s]) or (s>column[ii,0]) then begin can:=false; exit; end;
end;
can:=true;
end;
procedure find(x,y,z:longint);
var
ii,jj:longint;
begin
if x=(n+1) then
begin
inc(ans);
writeln(fout,ans);
for ii:=1 to n do
begin
for jj:=1 to n do
write(fout,g[ii,jj]);
writeln(fout);
end;
end else begin
if y=line[x,0]+1 then
begin
find(x+1,1,1);
end else begin
for ii:=z to last[x,y] do
begin
for jj:=1 to line[x,y] do
g[x,ii+jj-1]:='*';
if can(x,ii,line[x,y]) then
find(x,y+1,ii+line[x,y]+1);
for jj:=1 to line[x,y] do
g[x,ii+jj-1]:=' '
end;
end;
end;
end;
begin
assign(fin,'island.in'); reset(fin);
assign(fout,'island.out'); rewrite(fout);
readln(fin,n);
for i:=1 to n do
begin
j:=0;
repeat
inc(j);
read(fin,line[i,j]);
until line[i,j]=0;
line[i,0]:=j-1;
end;
for i:=1 to n do
begin
j:=0;
repeat
inc(j);
read(fin,column[i,j]);
until column[i,j]=0;
column[i,0]:=j-1;
end;
//************************************
for i:=1 to n do
begin
last[i,line[i,0]+1]:=n+2;
for j:=line[i,0] downto 1 do
begin
last[i,j]:=last[i,j+1]-line[i,j]-1;
end;
end;
//************************************
ans:=0;
for i:=1 to 8 do g[0,i]:=' ';
for i:=1 to 8 do for j:=1 to 8 do g[i,j]:=' ';
find(1,1,1);
if ans=0 then writeln(fout,'no');
close(fin);
close(fout);
end.