```
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
char map[305][205];
bool vis[305][305];
int start_x,start_y;
int point;
int n,m;
struct place{
int x,y;
}p;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
bool check(int x,int y){
if(map[x][y]!='#' && vis[x][y] == 0 && x>=1 && y>=1 && x<=n &&y<=m){
return 1;
}
return 0;
}
bool check_door(int x,int y){
if(map[x][y]>='A' && map[x][y]<='Z'){
return 1;
}
return 0;
}
place next_door(int x,int y){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if((i!=x || j!=y) && map[i][j]==map[x][y]){
p.x=i;
p.y=j;
return p;
}
}
}
}
struct node{
int x,y;
int step;
}cow;
queue <node> q;
void bfs(int x,int y){
node tmp;
tmp.x=x;
tmp.y=y;
tmp.step=0;
q.push(tmp);
vis[x][y]=1;
while(!q.empty()){
cow=q.front();
q.pop();
if(map[cow.x][cow.y]=='='){
point=cow.step;
return;
}
if(check_door(cow.x,cow.y)){
place next=next_door(cow.x,cow.y);
cow.x=next.x;
cow.y=next.y;
}
for(int i=0;i<4;i++){
int xx=cow.x+dx[i];
int yy=cow.y+dy[i];
if(check(xx,yy)){
vis[xx][yy]=1;
node t;
t.x=xx;
t.y=yy;
t.step=cow.step+1;
q.push(t);
}
}
}
}
int main()
{memset(vis,0,sizeof(vis));
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>map[i][j];
if(map[i][j]=='@'){
start_x=i;
start_y=j;
}
}
}
// cout<<endl;
// for(int i=1;i<=n;i++){
// for(int j=1;j<=m;j++){
// cout<<map[i][j];
// }
// cout<<endl;
// }
bfs(start_x,start_y);
printf("%d",point);
return 0;
}
```
调了一晚上了,56pts,真的找不到错误了,求助
by 王宏宇11 @ 2023-09-03 21:36:00
发现是m打成n了,裂开,但还是86分。。这下真找不着了呜呜呜
by 王宏宇11 @ 2023-09-03 21:57:15
此贴终结,lz是个sb,把3打成2了
by 王宏宇11 @ 2023-09-03 22:19:06