样例过了却0分
  • 板块P3395 路障
  • 楼主Cong256
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/1/23 18:24
  • 上次更新2024/1/23 20:30:44
查看原帖
样例过了却0分
1106396
Cong256楼主2024/1/23 18:24

救命!!!!!!!!!!!!!!!

#include<bits/stdc++.h> 
using namespace std;
struct node{
	int x, y;
};
int n;
struct time{
	int x,y,t;
}asd[1000010];
int a[1010][1010];
bool b[1010][1010];
int x_[5]={1,0,-1,0},
	y_[5]={0,1,0,-1};
int main() {
	int T;
	cin>>T;
	while(T--){
		memset(a,-1,sizeof(a));
		memset(b,1,sizeof(b));
		cin>>n;
		for(int i=0;i<=n*2-2;i++){
			cin>>asd[i].x>>asd[i].y;
			asd[i].t=i+1;
		}
		node start;
		cin>>start.x>>start.y;
		node now = start;
		queue<node>qu;
		a[start.x][start.y] = 0;
		qu.push(now);
		while(!qu.empty()) {
			now = qu.front(); 
			qu.pop();
			for(int i=0; i<4; i++) {
				int xx = now.x + x_[i], yy = now.y + y_[i];
				if(xx < 1 || xx > 30 || yy < 1 || yy > 30 ||a[xx][yy]!=-1||b[xx][yy]==false)continue;
				a[xx][yy] = a[now.x][now.y]+1;
				b[asd[a[xx][yy]].x][asd[a[xx][yy]].y]=false;
				qu.push((node){xx, yy});
			}
		}	
		if(a[1][1]!=-1)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}	
2024/1/23 18:24
加载中...