能跑起来但不输出
数组未越界
开的是全局变量
#include<bits/stdc++.h>
using namespace std;
const int Maxn=1000+6;
int a[Maxn][Maxn]={0};
struct P{
int flag[Maxn][Maxn];
int x;
int y;
};
queue<P> q;
int go[2][2]={{1,0},{0,1}};
int ma_x,ma_y,end_x,end_y;
int maxv=0;
int ans=0;
int bfs()
{
cout << "hah"<<endl;
P start;
start.flag[Maxn][Maxn]={0};
start.flag[0][0]=1;
start.flag[ma_x][ma_y]=1;
if(ma_x>=2 && ma_y>=1)
start.flag[ma_x-2][ma_y-1]=1;
if(ma_x>=1 && ma_y>=2)
start.flag[ma_x-1][ma_y-2]=1;
if(ma_y>=2)
start.flag[ma_x+1][ma_y-2]=1;
if(ma_y>=1)
start.flag[ma_x+2][ma_y-1]=1;
start.flag[ma_x+2][ma_y+1]=1;
start.flag[ma_x+1][ma_y+2]=1;
if(ma_x>=1)
start.flag[ma_x-1][ma_y+2]=1;
if(ma_x>=2)
start.flag[ma_x-2][ma_y+1]=1;
start.x = 0;
start.y = 0;
q.push(start);
while(!q.empty())
{
P be;
be = q.front();
q.pop();
for(int i=0;i<2;i++)
{
be.x = be.x + go[i][0];
be.y = be.y + go[i][1];
if(be.x>end_x||be.y>end_y||be.flag[be.x][be.y])
continue;
be.flag[be.x][be.y]=1;
q.push(be);
if(be.x == end_x && be.y == end_y) ans++;
}
}
return 0;
}
int main()
{ '
cin >> end_x >> end_y >> ma_x >> ma_y ;
bfs();
cout << ans;
return 0;
}