#include #include #include #include #include #include int main() { int H, W, Y, X; std::cin >> H >> W >> Y >> X; --Y; --X; std::vector A(H, std::vector(W)); for (int i = 0; i < H; ++i) { std::copy_n(std::istream_iterator(std::cin), W, A[i].begin()); } int S = A[Y][X]; A[Y][X] = 0; std::priority_queue> q; constexpr int dy[] {0, 1, 0, -1}, dx[] {1, 0, -1, 0}; for (int i = 0; i < 4; ++i) { const int ny = Y + dy[i], nx = X + dx[i]; if (0 <= ny && ny < H && 0 <= nx && nx < W) { q.emplace(-A[ny][nx], ny, nx); } } while (!q.empty()) { const auto [cs, cy, cx] = q.top(); q.pop(); if (S <= -cs) { std::cout << "No\n"; return 0; } S += -cs; for (int i = 0; i < 4; ++i) { const int ny = cy + dy[i], nx = cx + dx[i]; if (0 <= ny && ny < H && 0 <= nx && nx < W && A[ny][nx] != 0) { q.emplace(-A[ny][nx], ny, nx); A[ny][nx] = 0; } } } std::cout << "Yes\n"; }