题目大意:
#include <cstdio>
#include <algorithm>
#include <queue>
#define N 505
#define M 600005
#define INF 1000000000
using namespace std;
const int xx[]={-1,0,1,0},yy[]={
0,-1,0,1};
inline bool isdigit(const char& c) { return c>='0' && c<='9'; }
struct Point {
int x,y;
Point() {}
Point(int _x,int _y):x(_x),y(_y) {}
bool operator == (const Point& rhs) const { return x==rhs.x && y==rhs.y; }
}pos[10],to[N][N][4],s[N*N];
queue<Point> q1,q2;
int n,m,p,top,dfs_clock,f[10][10][N][N],mark[N][N][4];
char mp[N][N];
Poi