#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int DY[4] = {-1, 0, 1, 0}; const int DX[4] = {0, 1, 0, -1}; struct Node { int y; int x; ll value; Node(int y = -1, int x = -1, ll value = 0) { this->y = y; this->x = x; this->value = value; } bool operator>(const Node &n) const { return value > n.value; } }; int main() { int H, W, Y, X; cin >> H >> W >> Y >> X; priority_queue , greater> pque; ll A[H][W]; for (int y = 0; y < H; ++y) { for (int x = 0; x < W; ++x) { cin >> A[y][x]; } } for (int dir = 0; dir < 4; ++dir) { int ny = (Y - 1) + DY[dir]; int nx = (X - 1) + DX[dir]; if (ny < 0 || nx < 0 || H <= ny || W <= nx) continue; pque.push(Node(ny, nx, A[ny][nx])); } ll power = A[Y - 1][X - 1]; bool visited[H][W]; memset(visited, false, sizeof(visited)); visited[Y - 1][X - 1] = true; int cnt = 0; while (not pque.empty()) { Node node = pque.top(); pque.pop(); if (power <= node.value) continue; if (visited[node.y][node.x]) continue; visited[node.y][node.x] = true; power += node.value; ++cnt; // fprintf(stderr, "power: %lld\n", power); for (int dir = 0; dir < 4; ++dir) { int ny = node.y + DY[dir]; int nx = node.x + DX[dir]; if (ny < 0 || nx < 0 || H <= ny || W <= nx) continue; pque.push(Node(ny, nx, A[ny][nx])); } } if (cnt == H * W - 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }