#include #define int long long using namespace std; const int N=110; struct P{ int x,y,v; bool operator>(const P&a)const { return v>a.v; } }; vector

ve[N][N]; int n,m; int k,p; int sx,sy,tx,ty; int dx[]={-1,1,0,0},dy[]={0,0,1,-1}; int value[4]; char s[N][N]; bool vis[N][N]; int dist[N][N]; signed main(){ cin>>n>>m; for(int i=0;i<4;i++) cin>>value[i]; cin>>k>>p; cin>>sx>>sy>>tx>>ty; sx--,sy--,tx--,ty--; for(int i=0;i>s[i]; for(int i=0;i=n||y>=m||s[x][y]=='#') continue; if(s[x][y]=='@'){ ve[i][j].push_back({x,y,value[z]+p}); } else{ ve[i][j].push_back({x,y,value[z]}); } } } } memset(dist,0x3f,sizeof dist); priority_queue,greater

>q; q.push({sx,sy,0}); dist[sx][sy]=0; while(q.size()){ auto [x,y,v]=q.top(); q.pop(); if(vis[x][y]) continue; vis[x][y]=1; for(auto [nx,ny,w]:ve[x][y]){ if(dist[nx][ny]>dist[x][y]+w){ dist[nx][ny]=dist[x][y]+w; q.push({nx,ny,dist[nx][ny]}); } } } if(dist[tx][ty]<=k) cout<<"Yes"; else cout<<"No"; return 0; }