# Can anyone tell me what's wrong with my dfs solution ?

• I try to solve this problem by DFS,but I fail in case 69,

``````class Solution {
public:
int shortestDistance(vector<vector<int>>& maze, vector<int>& start, vector<int>& destination) {
int rs = maze.size(),cs = maze[0].size();
vector<vector<int>> direction = {{1,0},{-1,0},{0,1},{0,-1}};
vector<vector<int>>  cache(rs,vector<int> (cs,-1));//stored MIN distance from point[i][j] to destination,if no way set value to INT_MAX
vector<vector<bool>> visited(rs,vector<bool>(cs,true));//stored which point had visited
visited[start[0]][start[1]] = 0;
return dfs(maze,start,destination,direction,visited,rs,cs,cache);
}

int dfs(const vector<vector<int>> &maze,vector<int> &start,const vector<int> & destination,const vector<vector<int>> &drt,vector<vector<bool>> &visited,const int &rs,const int &cs,vector<vector<int>> &cache){
if(start==destination){
return 0;
}
if(cache[start[0]][start[1]]!=-1)
return cache[start[0]][start[1]]==INT_MAX?-1:cache[start[0]][start[1]];
int step;
cache[start[0]][start[1]]= INT_MAX;
for(int i=0;i<4;++i){
step = 0;
vector<int> tmp = dest(maze,start,drt[i],rs,cs,step);//rolling funtion
if(visited[tmp[0]][tmp[1]]){
visited[tmp[0]][tmp[1]] = false;
int substep = dfs(maze,tmp,destination,drt,visited,rs,cs,cache);
if(substep!=-1)
cache[start[0]][start[1]] = min(cache[start[0]][start[1]],step+substep);
visited[tmp[0]][tmp[1]] = true;
}
}
return cache[start[0]][start[1]]==INT_MAX?-1:cache[start[0]][start[1]];
}

vector<int> dest(const vector<vector<int>> &maze,vector<int> start,const vector<int>&drt,const int &rs,const int &cs,int &step){
vector<int> tmp = start;
start[0] += drt[0];
start[1] += drt[1];
if(start[0]<0||start[0]>=rs||start[1]<0||start[1]>=cs||maze[start[0]][start[1]]==1){
return tmp;
}
++step;
return dest(maze,start,drt,rs,cs,step);
}

``````

Here is the case I fail in.This cases is too long to display well..I am so sorry about that..

``````[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,1,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,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,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,1,0,1,1,0,0,1,1,1,1,0,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,1,1,0,0],[1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,1,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0],[1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0]]
[37,88]
[60,33]

``````

• My output is 202,but expected answer is 192.

• If the shortest distance path for a point actually directs to a visited node, your cache failed to catch that.

I get your point . So I set the visited[node] to true after checking its path , and it doesn't work?

• @yangyx hi,
I use the same way got the same error. It gives me a hard time! I believe dfs is not the right way to do this! Check the comments in this link http://codeforces.com/blog/entry/16579. Hope it helps!

• @tashia Thanks for your replaying~