文章

1

粉丝

0

获赞

0

访问

9

头像
生化武器2 题解:
P1124
发布于2025年2月23日 19:17
阅读数 9

DEV上运行没问题,但提交显示答案错误QAQ
 

#include <bits/stdc++.h> 
using namespace std;
const int maxn=100;
char mpt[maxn+5][maxn+5];
int flag[maxn+5][maxn+5];
int n,m,t;
int safe;
struct node{
	int sx,sy;
	int t;
};
int away[4][2]={0,1,0,-1,-1,0,1,0};

void san(int x,int y){
	safe=0;
	memset(flag,0,sizeof(flag));
	node yuan;
	yuan.sx=x;yuan.sy=y;
	yuan.t=0;
	queue<node> q;
	q.push(yuan);
	flag[x][y]=1;
	while(!q.empty()){
		node now=q.front();
		q.pop();
		int d=1;
		if(now.t<t){
			for(int i=0;i<4;i++){
				node f;
				f.sx=now.sx+away[i][0];
				f.sy=now.sy+away[i][1];
				f.t=now.t+1;
				if((mpt[f.sx][f.sy]=='.'||mpt[f.sx][f.sy]=='S')&&flag[f.sx][f.sy]==0){
					q.push(f);
					flag[f.sx][f.sy]=1;
					mpt[f.sx][f.sy]='G';
				}
			}
		}
		else{
			if(d==1){
				d=0;
				for(int i=1;i<=n;i++){
					for(int j=1;j<=m;j++){
						if(mpt[i][j]=='.'){
							mpt[i][j]='S';
						}
					}
				}
			}
			for(i...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发