BFS可以求得最短路,DFS会找到从当前点到图中叶子结点的路径. #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; int n,m,ans; ][]; ][]; struct node{ int x,y,dis; }; ][]={{,},{,},{-,},{,-}}; void bfs(int x,int y){ if(s[x][y]=='#') return ; memset(vis,,size…