#include using namespace std; #define rep(i, n) for(int i = 0; i < (int)n; ++i) #define FOR(i, a, b) for(int i = a; i < (int)b; ++i) #define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i) typedef long long ll; typedef long double ld; const int Inf = 1e9; const double EPS = 1e-9; const int MOD = 1e9 + 7; int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; int n, v, ox, oy; vector > g; using P = pair; using PP = pair; vector > dist; void dijkstra(int sx = 0, int sy = 0) { dist = vector >(n, vector(n, Inf)); dist[sx][sy] = 0; priority_queue, greater > pq; pq.push(PP(0, P(sx, sy))); while (!pq.empty()) { PP p = pq.top(); pq.pop(); int c = p.first; int vx = p.second.first, vy = p.second.second; rep (i, 4) { int nx, ny; nx = vx + dx[i], ny = vy + dy[i]; if (nx < 0 || ny < 0 || nx >= n || ny >= n) continue; if (dist[nx][ny] <= g[nx][ny] + c) continue; dist[nx][ny] = g[nx][ny] + c; pq.push(PP(dist[nx][ny], P(nx, ny))); } } } int main() { cin.tie(nullptr); ios::sync_with_stdio(0); cin >> n >> v >> ox >> oy; ox--, oy--; g = vector >(n, vector(n)); rep (i, n) rep (j, n) cin >> g[i][j]; dijkstra(); if (dist[n - 1][n - 1] < v) { cout << "YES" << endl; return 0; } if (ox >= 0 && oy >= 0) { int toO = 2 * (v - dist[ox][oy]); dijkstra(ox, oy); int toG = dist[n - 1][n - 1] - dist[ox][oy]; if (toG < 2 * toO) { cout << "YES" << endl; return 0; } } cout << "No" << endl; return 0; }