#include using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #define fi first #define se second typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; const int INF = 1e9; const ll MOD = 1e9 + 7; double EPS = 1e-8; int dx[] = {0, -1, 0, 1}; int dy[] = {-1, 0, 1, 0}; const int MAX_N = 210; int d[MAX_N][MAX_N][2]; int L[MAX_N][MAX_N]; int main() { cin.tie(0); ios::sync_with_stdio(false); rep(i, MAX_N) rep(j, MAX_N) rep(k, 2) d[i][j][k] = -INF; int N, V, OX, OY; cin >> N >> V >> OX >> OY; --OX; --OY; rep(i, N) rep(j, N) cin >> L[i][j]; d[0][0][0] = V; using P = pair; priority_queue, greater

> q; q.push({{V, 0}, {0, 0}}); auto isOutOfRange = [](int h, int w, int H, int W) { return h < 0 || h >= H || w < 0 || w >= W; }; while (!q.empty()) { auto p = q.top(); q.pop(); int l = p.fi.fi, b = p.fi.se, x = p.se.se, y = p.se.fi; if (d[y][x][b] > l) continue; // cout << x << ", " << y << ", " << b << " -> " << l << endl; rep(i, 4) { int nx = x + dx[i], ny = y + dy[i]; if (isOutOfRange(ny, nx, N, N)) continue; int nl = l - L[ny][nx]; // cout << " " << nx << ", " << ny << ", " << b << " -> " << nl << endl; if (d[ny][nx][b] < nl) { d[ny][nx][b] = nl; q.push({{nl, b}, {ny, nx}}); } if (ny == OY && nx == OX && b == 0) { if (d[ny][nx][1] < nl * 2) { d[ny][nx][1] = nl * 2; q.push({{nl * 2, 1}, {ny, nx}}); } } } } string yes = "YES", no = "NO"; bool f = max(d[N-1][N-1][0], d[N-1][N-1][1]) > 0; cout << (f ? yes : no) << endl; // rep(i, N) { // rep(j, N) { // cout << " (" << d[i][j][0] << ", " << d[i][j][1] <<") "; // } // cout << endl; // } return 0; }