#pragma GCC optimize("O3") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; using T = tuple; template inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;} template inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;} constexpr int MOD = 1e9 + 7; constexpr int inf = 1e9; constexpr long long INF = 1e18; constexpr double pi = acos(-1); constexpr double EPS = 1e-10; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int n, v; void dijkstra(int s, int o, vector> &G){ vector dist(n*n, inf); priority_queue, greater

> que; dist[s] = 0; que.emplace(0, s); while(que.size()){ int ccost, cv; tie(ccost, cv) = que.top(); que.pop(); if(dist[cv] < ccost) continue; for(auto nxt : G[cv]){ int nv, ncost; tie(nv, ncost) = nxt; if(dist[cv] + ncost < dist[nv]){ dist[nv] = dist[cv] + ncost; que.emplace(dist[nv], nv); } } } bool valid = false; if(o == -1){ if(0 < v - dist[n*n-1]) valid = true; } else{ if(0 < v - dist[n*n-1]) valid = true; if(dist[n*n-1] - dist[o] < 2 * (v - dist[o])) valid = true; } cout << (valid ? "YES" : "NO") << endl; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int ox, oy; cin>>n>>v>>ox>>oy; ox--, oy--; int l[n][n]; for(int i=0; i>l[i][j]; } int grid2graph[n][n]; int cnt = 0; int o = -1; for(int i=0; i> G(n*n); for(int i=0; i