记录编号 |
115647 |
评测结果 |
AAAAAAAA |
题目名称 |
[暑假培训2012] 寻找国都名 |
最终得分 |
100 |
用户昵称 |
FoolMike |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.002 s |
提交时间 |
2014-08-22 00:56:35 |
内存使用 |
0.20 MiB |
显示代码纯文本
var
k,m,n,a,b,r:longint;
z,z1:array[-10..110,-10..110]of char;
s:array[1..20]of string;
lu:string;
procedure sousuo(x,y,c:longint);
begin
if r=1 then exit;
if c=length(s[k])+1 then
begin
writeln('(',a,',',b,')',lu);
r:=1;
exit;
end;
if (z[x,y+1]=s[k][c])and(z1[x,y+1]<>'1') then
begin
lu:=lu+'1';
z1[x,y+1]:='1';
sousuo(x,y+1,c+1);
delete(lu,c-1,1);
z1[x,y+1]:='0';
end;
if (z[x,y-1]=s[k][c])and(z1[x,y-1]<>'1') then
begin
lu:=lu+'2';
z1[x,y-1]:='1';
sousuo(x,y-1,c+1);
delete(lu,c-1,1);
z1[x,y-1]:='0';
end;
if (z[x+1,y]=s[k][c])and(z1[x+1,y]<>'1') then
begin
lu:=lu+'3';
z1[x+1,y]:='1';
sousuo(x+1,y,c+1);
delete(lu,c-1,1);
z1[x+1,y]:='0';
end;
if (z[x-1,y]=s[k][c])and(z1[x-1,y]<>'1') then
begin
lu:=lu+'4';
z1[x-1,y]:='1';
sousuo(x-1,y,c+1);
delete(lu,c-1,1);
z1[x-1,y]:='0';
end;
if (z[x+1,y-1]=s[k][c])and(z1[x+1,y-1]<>'1') then
begin
lu:=lu+'5';
z1[x+1,y-1]:='1';
sousuo(x+1,y-1,c+1);
delete(lu,c-1,1);
z1[x+1,y-1]:='0';
end;
if (z[x-1,y+1]=s[k][c])and(z1[x-1,y+1]<>'1') then
begin
lu:=lu+'6';
z1[x-1,y+1]:='1';
sousuo(x-1,y+1,c+1);
delete(lu,c-1,1);
z1[x-1,y+1]:='0';
end;
if (z[x+1,y+1]=s[k][c])and(z1[x+1,y+1]<>'1') then
begin
lu:=lu+'7';
z1[x+1,y+1]:='1';
sousuo(x+1,y+1,c+1);
delete(lu,c-1,1);
z1[x+1,y+1]:='0';
end;
if (z[x-1,y-1]=s[k][c])and(z1[x-1,y-1]<>'1') then
begin
lu:=lu+'8';
z1[x-1,y-1]:='1';
sousuo(x-1,y-1,c+1);
delete(lu,c-1,1);
z1[x-1,y-1]:='0';
end;
end;
begin
assign(input,'country.in');
assign(output,'country.out');
reset(input);
rewrite(output);
readln(m,n);
for a:=1 to m do
begin
readln(s[1]);
for b:=1 to n do
z[a,b]:=s[1][b];
end;
s[1]:='';
readln(k);
for k:=1 to k do
begin
lu:='';
readln(s[k]);
r:=0;
for a:=1 to m do
for b:=1 to n do
if s[k][1]=z[a,b] then
begin
z1[a,b]:='1';
sousuo(a,b,2);
z1[a,b]:='0';
if r=1 then
begin
break;
break;
end;
end;
if r=0 then writeln('No found');
end;
close(input);close(output);
end.