哇(wa)以下几点:#5 #6 #9 #11 #13 #14 #16 #17 #22 #24 #25 #29 #30 #35。 代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,m,ans=0,a[10000][10000];
char ch;
bool bag[5005][5005];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
void dfs(int x,int y){
bag[x][y]=0;
ans+=a[x][y];
for(int i=0;i<4;i++){
int tx=x+dx[i],ty=y+dy[i];
if(tx>=1&&ty>=1&&tx<=n&&
ty<=m&&bag[tx][ty]){
dfs(tx,ty);
}
}
}
int main(){
IOS;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>ch;
if(ch=='S') a[i][j]=1;
if(ch=='M') a[i][j]=5;
if(ch=='L') a[i][j]=10;
bag[i][j]=1;
if(ch=='*') bag[i][j]=0;
}
}
int x,y;
cin>>x>>y;
dfs(x,y);
cout<<ans;
return 0;
}