#include #include #include #include #include #include using namespace std; typedef pair PI; typedef pair V; const int d[5]={0,1,0,-1,0}; int cost[201][201]; int dijkstra(PI s,PI t,int n){ int dist[202][202]; for(int i=1;i<=n;i++)for(int j=0;j<=n;j++)dist[i][j]=-1; for(int i=0;i<=n+1;i++)dist[0][i]=dist[i][0]=dist[n+1][i]=dist[i][n+1]=0; priority_queue,greater > que; que.push(make_pair(0,s)); while(que.empty()==false){ PI v=que.top().second; int di=que.top().first; que.pop(); if(dist[v.first][v.second]>=0)continue; dist[v.first][v.second]=di; for(int i=0;i<4;i++){ PI p=v; p.first+=d[i]; p.second+=d[i+1]; if(dist[p.first][p.second]>=0)continue; que.push(make_pair(di+cost[p.first][p.second],p)); } } return dist[t.first][t.second]; } int main(){ int N; int V; PI O; cin>>N>>V>>O.first>>O.second; for(int i=1;i<=N;i++) for(int j=1;j<=N;j++) cin>>cost[i][j]; auto st=make_pair(1,1); auto ed=make_pair(N,N); if(dijkstra(st,ed,N)0&&U-dijkstra(O,ed,N)>0) cout<<"YES"<