#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; #define INF 1000000000 int N; int L[205][205]; int vx[4] = {0,0,1,-1}; int vy[4] = {1,-1,0,0}; struct ST { int x, y, v; }; bool operator>(const ST& a, const ST& b){ return a.v > b.v; } int dijkstra(int sx, int sy, int gx, int gy){ bool visited[205][205]; REP(i,1,N+1){ REP(j,1,N+1){ visited[i][j] = false; } } priority_queue, greater > q; q.push((ST){sx,sy,0}); while(!q.empty()){ ST st = q.top(); q.pop(); if(visited[st.y][st.x]) continue; visited[st.y][st.x] = true; if(st.x == gx && st.y == gy) return st.v; rep(k,4){ int nx = st.x + vx[k], ny = st.y + vy[k]; if(1<=nx&&nx<=N && 1<=ny&&ny<=N){ q.push((ST){nx,ny,st.v+L[ny][nx]}); } } } return INF; } int main(){ int V, Ox, Oy; cin >> N >> V >> Ox >> Oy; REP(i,1,N+1){ REP(j,1,N+1){ cin >> L[i][j]; } } int ret1 = V - dijkstra(1,1,N,N); int ret2 = 0; if(Ox>=1){ int a = V-dijkstra(1,1,Ox,Oy); if(a>=0){ ret2 = 2*a - dijkstra(Ox,Oy,N,N); } } if(max(ret1, ret2) > 0) cout << "YES" << endl; else cout << "NO" << endl; return 0; }