问下,杭电1010这个哪里错了,求指导啊
#include <stdio.h>#include <stdlib.h>
int ansi,ansj,judge;
int n,m,t,why;
int d[4][2]={{0,-1},{0,1},{1,0},{-1,0}};
void dfs(int x ,int y ,int f,char maze[][10]){
int i,dx,dy;
if(f==t&&x==ansi&&y==ansj)
judge=1;
if(judge) return;
if((ansi+ansj-x-y+t-f)%2!=0) return;
for(i=0;i<4;i++){
dx=x+d[i][0],dy=y+d[i][1];
if(dx>=0&&dx<n&&dy>=0&&dy<m&&maze[dx][dy]!='X'){
maze[dx][dy]='X';
dfs(dx,dy,f+1,maze);
maze[dx][dy]='.';
}
}
}
int main()
{
char maze[10][10]={0};
int i,j,doori,doorj;
while(scanf("%d %d %d",&n,&m,&t)){
why=0,judge=0;
if(!(m||n||t)) break;
for(i=0;i<n;i++)
scanf("%s",maze[i]);
for(i=0;i<n;i++)
for(j=0;j<m;j++){
if(maze[i][j]=='S') doori=i,doorj=j;
else if(maze[i][j]=='D') ansi=i,ansj=j;
else why++;
}
if(why>=t-1) dfs(doori,doorj,0,maze);
if(judge) printf("YES\n");
else printf("NO\n");
}
return 0;
}