各位大神帮我看看有什么细节没考虑,有三个点没过

Var
     f:array[1..8]of char=(('D'),('C'),('B'),('A'),('H'),('G'),('F'),('E'));
     f2:array[1..8,1..2]of integer=((1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1),(1,0));
     i,j,n,m,w,x,y:integer;
     b,c:array[1..200]of integer;
     a:array[1..100,1..100]of char;
     d,s1,t:array[1..1000]of char;
     s:ansistring;

Function pd:boolean;
Var
     i:integer;
Begin
     for i:=1 to length(s) do
       if s1[i]<>t[i] then
         exit(false);
     exit(true);
End;

Procedure dfs(h,l,e:integer);
Begin
     if e=length(s) then
       if pd then
       begin
         b[i]:=x;
         c[i]:=y;
         d[i]:=f[j];
         exit;
       end;
     if (h+f2[j,1]>=1) and (h+f2[j,1]<=n) and (l+f2[j,2]>=1) and (l+f2[j,2]<=m)
       and (a[h+f2[j,1],l+f2[j,2]]=s[e+1]) then
       begin
         t[e+1]:=a[h+f2[j,1],l+f2[j,2]];
         dfs(h+f2[j,1],l+f2[j,2],e+1);
         t[e+1]:=' ';
       end;
End;

Begin
     readln(n,m,w);
     for i:=1 to n do
     begin
       for j:=1 to m-1 do
         read(a[i,j]);
       readln(a[i,m]);
     end;
     for i:=1 to w do
     begin
       readln(s);
       for j:=1 to length(s) do
         s1[j]:=s[j];
       for x:=1 to n do
         for y:=1 to m do
         begin
            t[1]:=a[x,y];
            if t[1]=s1[1] then
              for j:=1 to 8 do
                dfs(x,y,1);
         end;
     end;
     for i:=1 to w do
       writeln(b[i],' ',c[i],' ',d[i]);
     readln;
End.

0 条评论

目前还没有评论...

信息

ID
1707
难度
8
分类
搜索 | 枚举 点击显示
标签
(无)
递交数
770
已通过
102
通过率
13%
上传者