#include using namespace std; int main() { int N, V, Ox, Oy; cin >> N >> V >> Ox >> Oy; int L[220][220]; for (int i = 0; i < N + 2; i++) { for (int j = 0; j < N + 2; j++) { L[i][j] = 100000; } } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cin >> L[j + 1][i + 1]; } } struct book { int vit, x, y, used; }; priority_queue, function> que( [](book a, book b) { if (a.used != b.used) return (bool)a.used; return a.vit < b.vit; }); que.push({V, 1, 1, 0}); int dp[220][220][2] = {}; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, -1, 0, 1}; while (!que.empty()) { auto now = que.top(); que.pop(); if (now.x == N && now.y == N) { cout << "YES" << endl; return 0; } if (dp[now.x][now.y][now.used] >= now.vit) continue; dp[now.x][now.y][now.used] = now.vit; if (now.x == Ox && now.y == Oy && now.used == 0) { now.vit *= 2; now.used = 1; que.push(now); continue; } for (int i = 0; i < 4; i++) { int nx = now.x + dx[i], ny = now.y + dy[i]; int nv = now.vit - L[nx][ny]; if (nv > 0) { que.push({nv, nx, ny, now.used}); } } } cout << "NO" << endl; }