社区讨论
同一份代码 每次测评不同点RE 求助
P3395路障参与者 5已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @loc31uww
- 此快照首次捕获于
- 2023/10/30 07:09 2 年前
- 此快照最后确认于
- 2023/11/04 13:10 2 年前
不是固定点RE 每次测评会在不同的点RE 有时还会显示编译失败 有没有大佬可以麻烦解答一下呢
CPP#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;
}
回复
共 6 条回复,欢迎继续交流。
正在加载回复...