rt. 昨天写成这样就再没调出来,不知道哪错了,求各位大佬指正
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
const int maxn=250;
const int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
char mp[maxn][maxn];
//bool vis[maxn][maxn];
int sx,sy,ex,ey;
int n,m,qry,r,c,eng[maxn][maxn];
struct node{int x,y,e;};
queue<node>q;
void bfs(){
while(!q.empty()){
int x=q.front().x,y=q.front().y,e=q.front().e;
q.pop();
// cout<<"---"<<x<<" "<<y<<" "<<e<<"\n";
if(mp[x][y]=='T'){
cout<<"Yes";
exit(0);
}
for(int i=0;i<4;i++){
int dx=x+d[i][0],dy=y+d[i][1];
if(dx>=0&&dx<n&&dy>=0&&dy<m&&mp[dx][dy]!='#'/*&&!vis[dx][dy]*/){
if(eng[dx][dy]>=0&&e+eng[dx][dy]-1>0){
q.push({dx,dy,e+eng[dx][dy]-1});
eng[dx][dy]=0;
}
// vis[dx][dy]=1;
}
}
}
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++)cin>>mp[i];
cin>>qry;
for(int i=0;i<qry;i++){
cin>>r>>c;
cin>>eng[r-1][c-1];
// cout<<r-1<<" "<<c-1<<" "<<eng[r-1][c-1]<<"\n";
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(mp[i][j]=='S')sx=i,sy=j;
if(mp[i][j]=='T')ex=i,ey=j;
}
}
// cout<<sx<<" "<<sy<<" "<<ex<<" "<<ey<<"\n";
q.push({sx,sy,eng[sx][sy]});
// for(int i=0;i<n;i++){
// for(int j=0;j<m;j++)cout<<eng[i][j]<<"";
// cout<<"\n";
// }
bfs();
cout<<"No";
return 0;
}
/*
4 4
S...
#..#
#...
..#T
4
1 1 3
1 3 5
3 2 1
2 3 1
*/