#include #include using namespace std; //#define DISABLE_PRINT #if defined(ENABLE_PRINT) && !defined(DISABLE_PRINT) #define P(...) fprintf(stderr, __VA_ARGS__) #define P2(fmt) fprintf(stderr, fmt) #define LP fprintf(stderr, "L: %d\n", __LINE__) #else #define P(...) ((void)0) #define P2(fmt) ((void)0) #define LP ((void)0) #endif #define rep(i, n) for(int i = 0; i < (int)(n); ++i) #define ALL(x) x.begin(),x.end() using ll = long long; using ull = unsigned long long; pair diffs[] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} }; int main(int, const char**) { int H, W, Y, X; cin >> H >> W >> Y >> X; Y--; X--; struct V { int y; int x; int v; }; vector> done(H, vector(W)); vector> A(H, vector(W)); rep(i, H) rep(j, W) cin >> A[i][j]; ll p = 0; p += A[Y][X]; auto comp = [](const V& a, const V& b) { return a.v > b.v; }; priority_queue, decltype(comp)> q{comp}; auto push = [&](int y, int x) { P("pos(%d, %d)\n", y, x); assert(done[y][x]); for(auto diff : diffs) { auto ny = y + diff.first; auto nx = x + diff.second; if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue; if(done[ny][nx]) continue; q.push({ny, nx, A[ny][nx]}); done[ny][nx] = true; } }; done[Y][X] = true; push(Y, X); int count = 0; while(!q.empty()) { auto t = q.top(); q.pop(); if(p <= t.v) break; p += t.v; push(t.y, t.x); count++; } if(count == H * W - 1) { cout << "Yes" << endl; } else cout << "No" << endl; return 0; }