qwq实在不会改
```cpp
#include<iostream>
using namespace std;
long long dt[1005][1005];
long long startx,starty,endx,endy,n;
char a;
bool flag;
void move(int jd)
{
for(int i=1;i<=n;i++)
{
for(int ii=1;ii<=n;ii++)
{
if (dt[i][ii]==jd-1)
{
if (dt[i-1][ii]==0) {flag=1;dt[i-1][ii]=jd;}
if (dt[i+1][ii]==0) {flag=1;dt[i+1][ii]=jd;}
if (dt[i][ii-1]==0) {flag=1;dt[i][ii-1]=jd;}
if (dt[i][ii+1]==0) {flag=1;dt[i][ii+1]=jd;}
}
}
}
if (flag==0) return;
flag=0;
if (dt[startx][starty]==0) move(jd+1);
else return;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
for(int ii=1;ii<=n;ii++)
{
cin>>a;
if (a-48==1) dt[i][ii]=-1;
else dt[i][ii]=0;
}
}
cin>>startx>>starty>>endx>>endy;
dt[endx][endy]=1;
move(2);
if (dt[startx][starty]-1!=-1) cout<<dt[startx][starty]-1;
}
```
by ⚡小林孑⚡ @ 2018-12-07 22:54:20
@[zws666](/space/show?uid=119959) 谢谢,我刚刚找到错误了
by Rbu_nas @ 2018-12-07 23:00:22
int我用的是%s
char就过了
by Rbu_nas @ 2018-12-07 23:00:43