提交记录 27896


用户 题目 状态 得分 用时 内存 语言 代码长度
an_apple test. 自定义测试 Accepted 100 41.77 us 36 KB C++ 828 B
提交时间 评测时间
2025-02-09 22:00:56 2025-02-09 22:00:57
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const int N=2e3;
int n,m,dx[]{0,0,-1,1},dy[]{-1,1,0,0},sx,sy;
char a[N][N];
struct node{int px,py,step;};
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){
		cin>>a[i][j];
		if(a[i][j]=='E') sx=i,sy=j;
	}
	int st=0,ans=0;
	vector<pair<int,int> > v;
	queue<node> q;
	q.push({sx,sy,0});
	while(!q.empty()){
		node p=q.front();
		int x=p.px,y=p.py,z=p.step;
		for(int i=0;i<4;i++){
			int nx=x+dx[i],ny=y+dy[i];
			if(nx<1||ny<1||nx>n||ny>m||a[nx][ny]=='T') continue;
			if('1'<=a[nx][ny]&&a[nx][ny]<='9') v.push_back(make_pair(z+1,a[nx][ny]-48));
			else if(a[nx][ny]=='S') st=z+1;
			q.push({nx,ny,z+1});
			a[nx][ny]='T';
		}		
		q.pop();
	}
	for(auto i:v)if(i.first<=st) ans+=i.second;
	cout<<ans;
	
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #141.77 us36 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2025-03-14 14:38:11 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠