#include #include #include #include #include #include #include #define ll long long #define PLL pair #define VS vector #define VL vector #define rep(i,a) for (ll i=0;i (const NODE &node1, const NODE &node2) { return node1.dist > node2.dist; } NODE nodes[210][210]; bool flag[210][210]; */ ll dist[210][210]; ll cost[210][210]; int dy[] = { 1, 0, -1, 0 }; int dx[] = { 0, 1, 0, -1 }; ll N, V, Ox, Oy; void diskstra(int y, int x){ rep(i, N) rep(j, N) dist[i][j] = INF; // priority_queue >, greater > > que; que.push(make_pair(0, make_pair(y, x))); dist[y][x] = 0; while (!que.empty()){ auto c = que.top().first; auto now = que.top().second; que.pop(); // if(dist[now.first][now.second] < c) continue; rep(i, 4){ int ny = now.first + dy[i], nx = now.second + dx[i]; if (!(0 <= ny && ny < N && 0 <= nx && nx < N)) continue; if (dist[ny][nx] <= c + cost[ny][nx]) continue; dist[ny][nx] = c + cost[ny][nx]; que.push(make_pair(dist[ny][nx], make_pair(ny, nx))); } } } /* void update(priority_queue ,greater > &pq,NODE node,ll x, ll y) { //cout << "update:" << x << " " << y << flag[x][y]< cost) { nodes[x][y].dist = cost; if (!flag[x][y]) { flag[x][y] = true; pq.push(nodes[x][y]); //cout << "update_pq_size=" << pq.size() << endl; } } } */ int main() { cin >> N >> V >> Ox >> Oy; Ox--; Oy--; rep(i, N) rep(j, N) { /* cin >> nodes[i][j].level; nodes[i][j].dist = INF; nodes[i][j].x = i; nodes[i][j].y = j; flag[i][j] = false; */ cin >> cost[i][j]; } /* priority_queue, greater > pq; nodes[0][0].dist = 0; pq.push(nodes[0][0]); NODE node; while (!pq.empty()) { node = pq.top(); pq.pop(); //cout << node.x << " " << node.y << endl; flag[node.x][node.y] = false; if (node.x > 0) { update(pq, node, node.x - 1, node.y); } if (node.x < N - 1) { update(pq, node, node.x + 1, node.y); } if (node.y > 0) { update(pq, node, node.x, node.y - 1); } if (node.y < N - 1) { update(pq, node, node.x, node.y + 1); } //cout << "main_pq_size=" << pq.size() << endl; }ll start_to_end = V - nodes[N - 1][N - 1].dist; if (nodes[N-1][N-1].dist 0) { update(pq, node, node.x - 1, node.y); } if (node.x < N - 1) { update(pq, node, node.x + 1, node.y); } if (node.y > 0) { update(pq, node, node.x, node.y - 1); } if (node.y < N - 1) { update(pq, node, node.x, node.y + 1); } //cout << "main_pq_size=" << pq.size() << endl; } if (nodes[N-1][N-1].dist dist[N - 1][N - 1]){ cout << "YES" << endl; } else{ cout << "NO" << endl; } return 0; }