前言
以前,不知道为啥没人关注我,可能是太菜了,但是现在红名绿钩了,还是没多少人,属实逆天
30粉可算是凑齐了,发个粉福,也许没人看(?)
粉福
爆码风
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
int n,m,ex,ey;
bool a[107][107];
struct man{
int x,y,step;
};
queue<man> q;
int dx[4]={1,-1,0, 0};
int dy[4]={0,0, 1,-1};
void bfs(){
while(!q.empty()){
int x=q.front().x;
int y=q.front().y;
int step=q.front().step;
q.pop();
if(x==ex && y==ey){
cout << step;
exit(0);
}
for(int i=0;i<4;i++){
int nx=x+dx[i],ny=y+dy[i];
if(a[nx][ny]){
a[nx][ny]=0;
q.push(man{nx,ny,step+1});
}
}
}
}
int main(){
cin >> n >> m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char c;
cin >> c;
if(c=='#') a[i][j]=0;
else a[i][j]=1;
if(c=='m'){
q.push(man{i,j,0});
}else if(c=='d'){
ex=i,ey=j;
}
}
}
bfs();
cout << -1;
return 0;
}不许抄我代码啊!!!
爆学校
咳咳,来个拼音缩写:GDSYZX
好吧,直接爆答案:广东实验中学
至于哪个校区,下次再爆
支持壶关
欢迎私信聊天,欢迎壶关