제출 #754952

#제출 시각아이디문제언어결과실행 시간메모리
754952IloveN사이버랜드 (APIO23_cyberland)C++17
8 / 100
3044 ms36896 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back #define all(vr) vr.begin(), vr.end() using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; struct vertex { int v, d; double dist; bool operator < (const vertex &obj) const { return mp(dist, v) > mp(obj.dist, obj.v); } }; const int N = 1e5 + 10; vector<pii> G[N]; int vis[N]; double dist[N][40]; void dfs(int u, vi& vt) { vis[u] = 1; vt.eb(u); for (pii pa : G[u]) if (!vis[pa.fi]) dfs(pa.fi, vt); } double solve(int n, int m, int k, int h, vi x, vi y, vi c, vi arr) { for (int i = 0; i < n; ++i) G[i].clear(); for (int i = 0; i < m; ++i) { int u = x[i], v = y[i], w = c[i]; G[u].eb(v, w); G[v].eb(u, w); } for (int i = 0; i < n; ++i) vis[i] = 0; vi vt; dfs(0, vt); priority_queue<vertex> q; for (int i = 0; i < n; ++i) for (int j = 0; j <= k; ++j) dist[i][j] = 1e18; dist[0][0] = 0; q.push({0, 0, 0}); for (int x : vt) if (!arr[x]) dist[x][0] = 0, q.push({x, 0, 0}); while (!q.empty()) { int u = q.top().v, d = q.top().d; double w = q.top().dist; q.pop(); if (w != dist[u][d] || u == h) continue; for (pii pa : G[u]) { if (dist[u][d] + pa.se < dist[pa.fi][d]) { dist[pa.fi][d] = dist[u][d] + pa.se; q.push({pa.fi, d, dist[pa.fi][d]}); } if (arr[u] == 2 && d < k && dist[u][d] / 2 + pa.se < dist[pa.fi][d + 1]) { dist[pa.fi][d + 1] = dist[u][d] / 2 + pa.se; q.push({pa.fi, d + 1, dist[pa.fi][d + 1]}); } } } double res = 1e18; for (int i = 0; i <= k; ++i) res = min(res, dist[h][i]); return res; }
#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...