此代码为什么会RE掉?
  • 板块学术版
  • 楼主DevilsFlame
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/1/10 13:22
  • 上次更新2024/1/10 13:22:31
查看原帖
此代码为什么会RE掉?
1050431
DevilsFlame楼主2024/1/10 13:22
#include<bits/stdc++.h>
using namespace std;
char s[101][100001];
int v[101][100001],n,m,k,i,j,x,y,ey,ex,ans=-999,xxx;
int h[4]={0,0,1,-1};
queue<int> xx;//血量
queue<int> qx;//行
queue<int> qy;//列
bool p(int x,int xx){//判断是否可走
	if(v[ex+x][ey+1]==-1)//有柱子
		return 0;
	if(xx-v[x][y]<1)//血量
		return 0;
	if(ex+x>n||ex+x<1)//越界
		return 0;
	return 1;
}
int pc(char x){//判断
	switch(x){
		case '.':return 0;
		default:return x-48;
		case '@':return 0;
		case 'l':return -1;
	}
	return 0;
}
int main(){
	cin>>k>>n>>m;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			cin>>s[i][j];
			v[i][j]=pc(s[i][j]);
			if(s[i][j]=='@'){
				qy.push(j);
				qx.push(i);
				xx.push(k);
			}
		}
	while(qy.size()>0){
		ey=qy.front(),ex=qx.front(),xxx=xx.front();
		qy.pop(),xx.pop(),qx.pop();
		if(ey>m){//如果过了终点
			ans=max(ans,xxx);
			continue;
		}
		for(i=1;i<=3;i++){
			if(p(h[i],xxx)){//读入
				qx.push(ex+h[i]);
				xx.push(xxx-v[ex][ey]);
				qy.push(ey+1);
			}
		}
	}
	if(ans<1){
		cout<<"Wrong"<<endl;
		return 0;
	}
	cout<<ans<<endl;
	return 0;
}
2024/1/10 13:22
加载中...