$N*M>16384$ ,有可能 $1*16384$ , $1005$ 是会炸的。
by hncsxzx @ 2022-09-22 07:49:36
@[hncsxzx](/user/492791) 没用
by Mr_Gengar @ 2022-09-22 20:43:27
@[Infi_nut ](https://www.luogu.com.cn/user/661135)所以说你是怎么改的呢?
by hncsxzx @ 2022-09-23 07:36:49
AC代码
```cpp
#include <bits/stdc++.h>
using namespace std;
char a[205][205];
bool l[205][205], b;
int timex[205][205], minx = 99999999;
int sx, sy, ex, ey;
int n, m, dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int xx[4] = {0, 0, 1, -1}, yy[4] = {1, -1, 0, 0};
struct node
{
int x, y;
};
queue<node> q;
int main()
{
cin >> n >> m;
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
cin >> a[i][j];
}
}
while(1)
{
cin >> sx >> sy >> ex >> ey;
if( sx == 0 )
{
return 0;
}
timex[ex][ey] = 1;
node x = {ex, ey};
q.push(x);
for (int i = 0;i < 8;i++)
{
int ax = sx, ay = sy;
while(ax > 0 && ay > 0 && ax <= n && ay <= m && a[ax][ay] != 'X')
{
ax += dx[i];
ay += dy[i];
l[ax][ay] = 1;
}
l[ax][ay] = 0;
}
while(q.size())
{
node u = q.front();
q.pop();
for (int i = 0;i <= 3;i++)
{
node tmp = u;
tmp.x += xx[i];
tmp.y += yy[i];
if( tmp.x > n || tmp.y > m || tmp.x < 1 || tmp.y < 1 || a[tmp.x][tmp.y] == 'X')
{
continue;
}
if( timex[tmp.x][tmp.y] == 0)
{
timex[tmp.x][tmp.y] = timex[u.x][u.y] + 1;
q.push(tmp);
}
if(l[tmp.x][tmp.y] == 1)
{
minx = min(minx, timex[tmp.x][tmp.y]);
b = 1;
}
}
}
if( b == 0 )
{
cout << "Poor Harry" << endl;
}
else
{
cout << minx - 1 << endl;
}
b = 0;
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
l[i][j] = 0;
timex[i][j] = 0;
}
}
minx = 99999999;
while(q.size())
{
q.pop();
}
}
}
```
by xujunlang2011 @ 2022-09-23 14:14:44
@[xujunlang2011](/user/738893) 我是需要调代码诶
by Mr_Gengar @ 2022-09-23 18:14:36