#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _MSC_VER #include #endif #define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i) #define rep(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define REV(v) v.rbegin(), v.rend() #define MEMSET(v, s) memset(v, s, sizeof(v)) #define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end()) #define MP make_pair #define MT make_tuple using namespace std; typedef long long ll; typedef pair P; const int N = 210; int dd[2][N][N]; int L[N][N]; int dx[] = { 0, 1, 0, -1 }; int dy[] = { -1, 0, 1, 0 }; int n; void dijk(int sx, int sy, int k){ int (*dist)[N] = dd[k]; rep(i, N) rep(j, N) dist[i][j] = 1e9; dist[sy][sx] = 0; priority_queue, vector>, greater>> q; q.push(MT(0, sx, sy)); while (!q.empty()){ auto t = q.top(); q.pop(); int d, x, y; tie(d, x, y) = t; if (dist[y][x] < d) continue; rep(dir, 4){ int nx = x + dx[dir], ny = y + dy[dir]; if (nx < 0 || nx >= n || ny < 0 || ny >= n) continue; int nd = d + (!k?L[ny][nx]:L[y][x]); if (dist[ny][nx] <= nd) continue; dist[ny][nx] = nd; q.push(MT(nd, nx, ny)); } } } int main(){ cin.tie(0); ios::sync_with_stdio(false); int v, ox, oy; cin >> n >> v >> ox >> oy; rep(i, n) rep(j, n) cin >> L[i][j]; --ox, --oy; dijk(0, 0, 0); dijk(n - 1, n - 1, 1); bool b = dd[0][n - 1][n - 1] < v; if (ox >= 0 && oy >= 0){ int x = v - dd[0][oy][ox]; if (x >= 0 && x * 2 > dd[1][oy][ox]) b = true; } cout << (b ? "YES":"NO") << endl; return 0; }