#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N, V; int G[200][200] = {}; int dp[200][200] = {}; int O[2]; void dijkstra(int sx, int sy) { rep(x, N) rep(y, N) dp[x][y] = -1; priority_queue>> Q; Q.push({ 0,{sx,sy} }); while (Q.size()) { int d = Q.top().first; int x = Q.top().second.first; int y = Q.top().second.second; Q.pop(); if (dp[x][y] != -1) continue; dp[x][y] = -d; if (x != 0) Q.push({ d - G[x - 1][y],{x - 1,y} }); if (y != 0) Q.push({ d - G[x][y - 1],{x,y - 1} }); if (x != N - 1) Q.push({ d - G[x + 1][y],{x + 1,y} }); if (y != N - 1) Q.push({ d - G[x][y + 1],{x,y + 1} }); } } int main() { cin >> N >> V; cin >> O[0] >> O[1]; O[0]--; O[1]--; rep(y, N) rep(x, N) cin >> G[x][y]; dijkstra(0, 0); if (dp[N - 1][N - 1] < V) { cout << "YES" << endl; return 0; } if (O[0] == -1) { cout << "NO" << endl; return 0; } V = (V - dp[O[0]][O[1]]) * 2; dijkstra(O[0], O[1]); if (dp[N - 1][N - 1] < V) { cout << "YES" << endl; return 0; } cout << "NO" << endl; return 0; }