救命0分!!!!!!!!!!!
#include<bits/stdc++.h>
using namespace std;
int n,m;
int ans=0;
int sx,sy;
char a[1005][1005];
bool vis[1005][1005];
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
struct node{
int x;
int y;
};
bool check(int x,int y){
return x>=1&&x<=n&&y>=1&&y<=m;
}
void bfs(int x,int y){
queue<node>q;
node tmp;
tmp.x=x;
tmp.y=y;
q.push(tmp);
vis[x][y]=true;
while(!q.empty()){
node now=q.front();
q.pop();
for(int i=0;i<4;i++){
int nx=now.x+dx[i];
int ny=now.y+dy[i];
if(!check(nx,ny)||vis[nx][ny]|a[nx][ny]=='*'){
continue;
}else{
if(a[nx][ny]=='S'){
ans+=1;
}else{
if(a[nx][ny]=='M'){
ans+=5;
}
else{
ans+=10;
}
}
vis[nx][ny]=true;
tmp.x=nx;
tmp.y=ny;
q.push(tmp);
}
}
}
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
cin>>sx>>sy;
if(a[sx][sy]=='L')ans+=10;
if(a[sx][sy]=='M')ans+=5;
if(a[sx][sy]=='S')ans++;
bfs(sx,sy);
cout<<ans;
return 0;
}
样例都过,为啥错啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊