#include"iostream" #include"cstdio" #include"queue" #include"cstring" using namespace std; const int N=106; const int mod=1000000; const int inf=123456789; int n,m,s_x,s_y,s_face,e_x,e_y; int step[N][N][4],cnt[N][N][4],flag[N][N][4]; char map[N][N]; int dir[4][2]={-1,0, 0,-1, 1,0, 0,1}; struct node{ int x,y,step,face; }; void bfs() { int i; node now,next; queueq; now.x=s_x; now.y=s_y; now.step=0; now.face=s_face; step[now.x][now.y][now.face]=0; cnt[now.x][now.y][now.face]=1; memset(flag,0,sizeof(flag)); q.push(now); while(!q.empty()) { now=q.front(); q.pop(); if(flag[now.x][now.y][now.face]) continue; flag[now.x][now.y][now.face]=1; for(i=0;i<4;i++) if(step[now.x][now.y][now.step]<=step[e_x][e_y][i]) break; if(i>=4) return ; next.x=now.x+dir[now.face][0]; next.y=now.y+dir[now.face][1]; next.step=now.step+1; next.face=now.face; while(0<=next.x && next.x