不是固定点RE 每次测评会在不同的点RE 有时还会显示编译失败 有没有大佬可以麻烦解答一下呢
#include <iostream>
#include <queue>
#include <cstring>
#include <cstdio>
using namespace std;
const int N = 1005;
bool vis[N][N];
int n,times;
struct point
{
int x,y;
};
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
void ini()
{
memset(vis,1,sizeof(vis));
for(int i = 1;i<=n;i++)
for(int j = 1;j<=n;j++)
vis[i][j] = 0;
times = 0;
// for(int i =0;i<=n+1;i++)
// {
// for(int j = 0;j<=n+1;j++)
// {
// printf("vis[%d,%d] = %d\n",i,j,(int)vis[i][j]);
// }
// cout<<endl;
// }
}
void input()
{
cin>>n;
}
void check()
{
if(times < 2*n-2)
{
int a,b;
cin>>a>>b;
vis[a][b] = 1;
times++;
}
}
void bfs()
{
bool ans = 0;
queue <point> q;
q.push({1,1});
while(!q.empty())
{
point now = q.front();
point to;
//printf("now : %d,%d\n",now.x,now.y);
q.pop();
if(now.x == n && now.y == n)
{
ans = 1;
break;
}
for(int i =0;i<4;i++)
{
to.x = now.x+dx[i];
to.y = now.y+dy[i];
if(!vis[to.x][to.y])
{
//printf("push:{%d,%d}\n",to.x,to.y);
q.push(to);
vis[to.x][to.y] = 1;
}
}
if(now.x == 1 && now.y == 1) continue;
check();
}
cout<<(ans ? "Yes" : "No")<<endl;
}
void work()
{
input();
ini();
bfs();
}
int main()
{
int t;
cin>>t;
while(t--) work();
return 0;
}