Submission #881654

#TimeUsernameProblemLanguageResultExecution timeMemory
881654tsumondaiCyberland (APIO23_cyberland)C++17
100 / 100
810 ms11052 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) #define __TIME (1.0 * clock() / CLOCKS_PER_SEC) using vi = vector<int>; using ar = pair<double, int>; typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; typedef pair<double, int> ar; const int N = 1e5 + 10; const double oo = DBL_MAX; int n, m, h; double ans = 0; bool vis[N]; double dis[N], dis2[N]; vector<ii> adj[N]; priority_queue<ar, vector<ar>, greater<ar>> pq; void dijkstra() { fill(vis, vis + n + 1, 0); foru(i, 0, n - 1) if (dis[i] < oo) pq.push({dis[i], i}); while (!pq.empty()) { auto tmp = pq.top(); pq.pop(); double D = tmp.fi; int a = tmp.se; if (vis[a] || a == h) continue; vis[a] = 1; for (auto tmp : adj[a]) { int b = tmp.fi, w = tmp.se; if (dis[b] > dis[a] + w) dis[b] = dis[a] + w, pq.push({dis[b], b}); } } ans = min(ans, dis[h]); } double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi A) { n = N, m = M, h = H, K = min(K, 67); fill(dis, dis + n, oo); ans = oo; foru(i, 0, n - 1) adj[i].clear(); foru(i, 0, m - 1) { adj[x[i]].push_back({y[i], c[i]}), adj[y[i]].push_back({x[i], c[i]}); } dis[0] = 0; dijkstra(); if (dis[h] >= oo) return -1; foru(i, 0, n - 1) if (dis[i] != oo) dis[i] = A[i] && i ? oo : 0; foru(i, 0, K) { dijkstra(); fill(dis2, dis2 + n, oo); for (int j = 0; j < n; j++) if (A[j] > 1) for (auto tmp : adj[j]) { int u = tmp.fi, w = tmp.se; dis2[u] = min(dis2[u], dis[j] / 2 + w); } for (int j = 0; j < n; j++) dis[j] = dis2[j]; } return ans; }

Compilation message (stderr)

cyberland.cpp: In function 'void dijkstra()':
cyberland.cpp:39:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   39 |   if (vis[a] || a == h) continue; vis[a] = 1;
      |   ^~
cyberland.cpp:39:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   39 |   if (vis[a] || a == h) continue; vis[a] = 1;
      |                                   ^~~
cyberland.cpp:38:10: warning: unused variable 'D' [-Wunused-variable]
   38 |   double D = tmp.fi; int a = tmp.se;
      |          ^
#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...