#include using namespace std; typedef pair P; typedef pair> PP; typedef long long ll; const double EPS = 1e-8; const int INF = 1e9; const int MOD = 1e9+7; int dy[] = {0,1,0,-1}; int dx[] = {1,0,-1,0}; bool bfs(int V,int ox,int oy,vector>L){ priority_queue,greater> pq; pq.push(make_pair(0,P(0,0))); int n = L.size(); vector>used(n,vector(n)); int StoO=0,StoG=0; while(!pq.empty()){ PP pp = pq.top();pq.pop(); int x = pp.second.first; int y = pp.second.second; int d = pp.first; if(x == ox && y == oy)StoO = d; if(x == n-1 && y == n-1)StoG = d; for(int i=0;i<4;i++){ int nx = x + dx[i],ny = y + dy[i]; if(nx < 0 || ny < 0 || nx >= n || ny >= n)continue; if(used[ny][nx])continue; used[ny][nx] = true; pq.push(make_pair(d+L[ny][nx],P(nx,ny))); } } pq.push(make_pair(0,P(ox,oy))); vector>used2(n,vector(n)); int OtoG=0; while(!pq.empty()){ PP pp = pq.top();pq.pop(); int x = pp.second.first; int y = pp.second.second; int d = pp.first; if(x == n-1 && y == n-1)OtoG = d; for(int i=0;i<4;i++){ int nx = x + dx[i],ny = y + dy[i]; if(nx < 0 || ny < 0 || nx >= n || ny >= n)continue; if(used2[ny][nx])continue; used2[ny][nx] = true; pq.push(make_pair(d+L[ny][nx],P(nx,ny))); } } //cout << StoG << " " << StoO << " " << OtoG << endl; if(StoG < V)return true; if(ox+oy>=0 && V-StoO > 0){ V = (V-StoO)*2; if(OtoG < V)return true; } return false; } int main(void) { int n,v,ox,oy; cin >> n >> v >> ox >> oy; ox--;oy--; vector>L(n,vector(n)); for(int i=0;i> L[i][j]; } } if(bfs(v,ox,oy,L))cout << "YES" << endl; else cout << "NO" << endl; return 0; }