제출 #1292871

#제출 시각아이디문제언어결과실행 시간메모리
1292871goulthen사이버랜드 (APIO23_cyberland)C++20
0 / 100
232 ms38956 KiB
#include <bits/stdc++.h> #include "cyberland.h" using namespace std; #define ld long double #define pii pair<int,int> #define ll long long #define rep(i,a,b) for(int i = a; i <= b; i++) const ll INF = 1e18+10; using z = pair<ld,pii>; double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) { K=min(K,30); vector<vector<ld>> dist(N, vector<ld>(K,INF)); vector<vector<bool>> vis(N, vector<bool>(K,0LL)); vector<vector<pii>> g(N); rep(i,0,M-1) { g[x[i]].emplace_back(y[i],c[i]); g[y[i]].emplace_back(x[i],c[i]); } priority_queue<z,vector<z>,greater<z>> pq; dist[0][0] = 0; pq.push({0,{0,0}}); while (!pq.empty()) { auto [d,f] = pq.top();pq.pop(); int u = f.first; int ck = f.second; if(vis[u][ck]) continue; //cout << u << ' ' << d << ' ' << ck << '\n'; vis[u][ck] = 1; if(u==H) continue; for(auto &[v,w] : g[u]) { int nd = d; if(arr[u] == 2 && ck<K-1) { nd /= 2; ck++; } if (arr[u] == 0) nd = 0; nd+=w; if (nd >= dist[v][ck]) continue; dist[v][ck] = nd; pq.push({dist[v][ck],{v,ck}}); } } ld ans = INF; rep(i,0,K-1) ans = min(ans,dist[H][i]); if(ans == INF) return -1; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...