#include #include #include #include #include #include #include #include using namespace std; #define ll long long #define Pll pair typedef struct edge{ ll to; ll cost; }Edge; typedef pair P; long long INF=1000000000000000000; int V; vector G[10000]; long long d[10000]; vector defa; void dijkstra(ll s){ priority_queue,greater

> que; fill(d,d+V,INF); d[s]=0; que.push(P(0,s)); while(!que.empty()){ P p=que.top();que.pop(); int v=p.second; if(d[v]d[v]+e.cost){ d[e.to]=d[v]+e.cost; que.push(P(d[e.to],e.to)); } } } } ostream& operator<<(ostream& os,vector a){ for(Edge e:a){ os<<"to:"<C; vector B; vector u; int main(){ cnt=0; ans=INF; cin>>H>>W>>U>>D>>R>>L>>K; V=H*W;//don't forget co=(U+1)*(D+1)*(R+1)*(L+1); C.resize(H); defa.resize(V); for(int i=0;i>C.at(i); for(int j=0;j>xs>>ys>>xt>>yt; xs--;ys--;xt--;yt--; for(int i=0;i>j)&1){ x=B.at(j).first; y=B.at(j).second; u.push_back({x,y}); C.at(x).at(y)='.'; } } for(int j=0;j>j)&1){ x=B.at(j).first; y=B.at(j).second; if(C.at(x+1).at(y)=='.'){ G[W*x+y].push_back({W*(x+1)+y,D}); G[W*(x+1)+y].push_back({W*x+y,U}); } if(C.at(x).at(y+1)=='.'){ G[W*x+y].push_back({W*x+y+1,R}); G[W*x+y+1].push_back({W*x+y,L}); } if(x>0 && C.at(x-1).at(y)=='.'){ G[W*x+y].push_back({W*(x-1)+y,U}); G[W*(x-1)+y].push_back({W*x+y,D}); } if(y>0 && C.at(x).at(y-1)=='.'){ G[W*x+y].push_back({W*x+y-1,L}); G[W*x+y-1].push_back({W*x+y,R}); } } } dijkstra(W*xs+ys); ans=min(ans,d[W*xt+yt]+(ll)u.size()*co); //cerr<defa.at(i)){ G[i].pop_back(); } } for(Pll j:u){ C.at(j.first).at(j.second)='@'; } } if(ans<=K)cout<<"Yes\n"; else cout<<"No\n"; cerr<<"ans:"<