#include #include #include #include #include #include #include using namespace std; #define FOR(i, s, e) for (int i = (s); i <= (e); i++) #define INF 1000000; int N, V; int Ox, Oy; int L[210][210]; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; int dp[210][210]; int dp2[210][210]; int main() { FOR(i, 0, 209) { FOR(j, 0, 209) { dp[i][j] = INF; dp2[i][j] = INF; } } cin >> N >> V; cin >> Ox >> Oy; FOR(i, 1, N) { FOR(j, 1, N) { cin >> L[j][i]; } } dp[1][1] = 0; while (true) { bool update = false; FOR(i, 1, N) { FOR(j, 1, N) { FOR(k, 0, 3) { int x = i + dx[k]; int y = j + dy[k]; if (1 <= x && x <= N && 1 <= y && y <= N) { if (dp[x][y] > dp[i][j] + L[x][y]) { dp[x][y] = dp[i][j] + L[x][y]; update = true; } } } } } if (update == false) break; } if (Ox != 0 && Oy != 0) { dp2[Ox][Oy] = 0; while (true) { bool update = false; FOR(i, 1, N) { FOR(j, 1, N) { FOR(k, 0, 3) { int x = i + dx[k]; int y = j + dy[k]; if (1 <= x && x <= N && 1 <= y && y <= N) { if (dp2[x][y] > dp2[i][j] + L[x][y]) { dp2[x][y] = dp2[i][j] + L[x][y]; update = true; } } } } } if(update == false) break; } } if (dp[N][N] < V) cout << "YES" << endl; else if (Ox != 0 && Oy != 0 && ((V - dp[Ox][Oy]) * 2 - dp2[N][N] > 0)) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }