#include #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i> h >> w >> y >> x; ll now; y--; x--; vector a(h, vector(w, 0LL)); multiset> ms; rep(i, h) rep(j, w) { cin >> a[i][j]; if(i == y && j == x) { now = a[i][j]; } } // cout << "aa" << endl; vector seen(h, vector(w, 0)); seen[y][x] = 1; int dy[4] = {-1, 0, 0, 1}; int dx[4] = {0, -1, 1, 0}; rep(k, 4) { // cout << k << endl; int i = dy[k] + y; int j = dx[k] + x; if(i < 0 || i > h - 1 || j < 0 || j > w - 1) continue; if(seen[i][j]) continue; seen[i][j] = 1; ms.insert({a[i][j], i, j}); } // cout << "aa" << endl; while(!ms.empty()) { // cout << "Jj" << endl; auto [d, ii, jj] = *ms.begin(); ms.erase(ms.begin()); // cout << ii << " " << jj << " " << d << " " << now << endl; if(d >= now) { cout << "No" << endl; return 0; } now += d; rep(k, 4) { int i = ii + dy[k]; int j = jj + dx[k]; if(i < 0 || i >= h || j < 0 || j >= w) continue; if(seen[i][j]) continue; seen[i][j] = 1; ms.insert({a[i][j], i, j}); } } cout << "Yes" << endl; return 0; }