>Description
>Input
>Output
>Sample Input1
2 2
+*
*U
1 1 2 2
>Sample Output1
-1
>解题思路
c原来是数组开小了。
BFS来做,ai,j,k表示从(x,y)到(i,j)进行了k次转换的最少步数,(x,y)为起始位置,因为每次旋转90°,所以旋转的次数只能在0~3次之间,所以数组不会炸。
>代码
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int xz[4]={
-1,0,1,0},yz[4]={
0,-1,0,1};
struct ooo
{
int xi,yi,c,sb; //xi,yi记录位置,c记录步数,sb记录旋转次数
}st[4000000]; //BFS队列(数组开大点)
int n,m,x,y,xx,yy,ans,head,tail,a[1005][1005][4];
bool k[1005][1005][4],yd[1005][1005][4]; //k记录每个格子四个门的状态,0上,1左,2下,3右,逆时针记录
char cc;
int main