#include #define rep(a,n) for (ll a = 0; a < (n); ++a) using namespace std; typedef long long ll; typedef pair P; typedef pair PP; typedef vector > Graph; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e18; //グリッド上のダイクストラ ll dx[4] = {0,0,1,-1}; ll dy[4] = {1,-1,0,0}; vector > g;//gはある座標から動くときにかかるコスト,distは最短距離 ll n; vector > dijkstra(ll sx, ll sy){ vector >dist(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(); ll c = p.first; ll vx = p.second.first; ll vy = p.second.second; rep(i,4){ ll 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[vx][vy] + c) continue; dist[nx][ny] = g[vx][vy] + c; pq.push(PP(dist[nx][ny], P(nx, ny))); } } return dist; } int main(){ ll v,ox,oy; cin >> n >> v >> ox >> oy; g.resize(n); rep(i,n)g[i].resize(n); rep(i,n)rep(j,n)cin>>g[i][j]; auto d = dijkstra(0,0); bool ans=false; if(d[n-1][n-1]0)ans = true; } if(ans)cout << "YES" << endl; else cout << "NO" << endl; return 0; }