记录编号 |
4258 |
评测结果 |
AAAAA |
题目名称 |
画海岛地图 |
最终得分 |
100 |
用户昵称 |
王瑞祥K |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.456 s |
提交时间 |
2008-10-15 21:37:43 |
内存使用 |
0.11 MiB |
显示代码纯文本
program island(input,output);
type
dz=array[1..10,0..10] of integer;
map=array[1..10,1..10] of char;
var
hang,lie:dz;
ans:map;
n,c:longint;
procedure print;
var i,j:longint;
begin
writeln(c);
for i:=1 to n do
begin
for j:=1 to n do
write(ans[i,j]);
writeln;
end;
end;
function check(ans:map):boolean;
var i,j,k,temp:longint; s:array[0..8] of integer;
begin
for i:=1 to n do
begin
j:=1;
fillchar(s,sizeof(s),0);
while (j<=n) do
begin
if (ans[j,i]='*')and(j=1)or(ans[j,i]='*')and(ans[j-1,i]=' ') then
begin inc(s[0]); inc(s[s[0]]); end;
if (ans[j,i]='*')and(j<>1)and(ans[j-1,i]='*') then inc(s[s[0]]);
inc(j);
end;
for k:=1 to s[0] do
if (s[0]<>lie[i,0])or(lie[i,k]<>s[k])then begin check:=false; exit;end;
end;
check:=true;
end;
procedure search(i,j,k:longint);
var x,y,p,q,r,v:longint;
begin
if i<=n then begin
for x:=j to n-hang[i,hang[i,0]]+1 do
begin
for y:=x to hang[i,k]+x-1 do
ans[i,y]:='*';
p:=i; q:=y+2; r:=k+1;
if k=hang[i,0] then begin p:=i+1; q:=1; r:=1; end;
search(p,q,r);
for y:=x to hang[i,k]+x-1 do ans[i,y]:=' ';
end;
end
else begin if check(ans)then begin c:=c+1; print;end;
exit;
end;
end;
procedure ini;
var i,j,temp:longint;
begin
assign(input,'island.in');assign(output,'island.out');
reset(input);rewrite(output);
readln(n);
c:=0;
for i:=1 to n do begin
hang[i,0]:=0; lie[i,0]:=0;
read(temp); j:=0;
while temp<>0 do begin
inc(hang[i,0]);
inc(j);
hang[i,j]:=temp;
read(temp);
end;
readln;
end;
for i:=1 to n do
begin
read(temp); j:=0;
while temp<>0 do begin
inc(lie[i,0]);
inc(j);
lie[i,j]:=temp;
read(temp);
end;
readln;
end;
for i:=1 to n do
for j:=1 to n do
ans[i,j]:=' ';
end;
begin
ini;
search(1,1,1);
if c=0 then writeln('no');
close(input);close(output);
end.