제출 #759556

#제출 시각아이디문제언어결과실행 시간메모리
759556IvanJ사이버랜드 (APIO23_cyberland)C++17
8 / 100
3072 ms27468 KiB
#include "cyberland.h" #include<bits/stdc++.h> #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 1e5 + 5, maxk = 35; const double inf = 1e18; double dist[maxn][maxk]; vector<ii> adj[maxn]; int vis[maxn]; void reach(int x) { if(vis[x]) return; vis[x] = 1; for(auto p : adj[x]) reach(p.x); } double solve(int N, int M, int K, int H, vector<int> u, vector<int> v, vector<int> c, vector<int> arr) { for(int i = 0;i < N;i++) for(int j = 0;j < maxk;j++) dist[i][j] = inf; for(int i = 0;i < N;i++) adj[i].clear(), vis[i] = 0; for(int i = 0;i < M;i++) adj[u[i]].pb({v[i], c[i]}), adj[v[i]].pb({u[i], c[i]}); reach(0); for(int i = 0;i < N;i++) if(arr[i] == 0 && vis[i] == 1) dist[i][0] = 0; dist[0][0] = 0; for(int k = 0;k <= K;k++) { set<pair<double, int>> s; for(int i = 0;i < N;i++) s.insert({dist[i][k], i}); while(s.size()) { auto state = *s.begin(); s.erase(state); int x = state.y; if(x == H) break; for(auto p : adj[x]) { int y = p.x; double cost = p.y; if(dist[x][k] + cost < dist[y][k]) { s.erase({dist[y][k], y}); dist[y][k] = dist[x][k] + cost; s.insert({dist[y][k], y}); } } } for(int i = 0;i < N;i++) { dist[i][k + 1] = dist[i][k]; if(arr[i] == 2) dist[i][k + 1] /= 2.0; } } return dist[H][K]; }
#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...