感觉问题在bfs那里(不是用bfs,只是这么取了个函数名)
#include<bits/stdc++.h>
using namespace std;
struct node{
int x,y;
}a[2510];
int n,m,cnt,maxx;
int dx[]={1,-1,0,0,1,1,-1,-1},dy[]={0,0,-1,1,-1,1,-1,1};
char ch[60][60],ch1[]={'|','|','-','-','\\','/','/','\\'};
int bfs(int x,int y){
int ans=1,tmp=0;
while(1){
for(int i=0;i<8;i++){
int xx=x+dx[i]*ans;
int yy=y+dy[i]*ans;
if(xx<=0||xx>n||yy<=0||yy>n||ch[xx][yy]!=ch1[i]){
tmp=1;
break;
}
}
if(tmp){
return ans-1;
}
ans++;
}
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>ch[i][j];
if(ch[i][j]=='+'){
cnt++;
a[cnt].x=i;
a[cnt].y=j;
}
}
}
for(int i=1;i<=cnt;i++){
maxx=max(maxx,bfs(a[i].x,a[i].y));
}
cout<<maxx;
return 0;
}