제출 #952621

#제출 시각아이디문제언어결과실행 시간메모리
952621Pring사이버랜드 (APIO23_cyberland)C++17
15 / 100
3014 ms14600 KiB
#include <bits/stdc++.h> using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) typedef pair<int, int> pii; typedef pair<double, int> pli; namespace { const int MXN = 100005; const double INF = 3.9e18; int n, m, k, h; vector<int> x, y, c, s; vector<pli> edge[MXN]; vector<pli> sr; double dis[MXN], ans; priority_queue<pli, vector<pli>, greater<pli>> pq; bitset<MXN> b; void DFS(int id) { debug(id); b[id] = true; if (s[id] == 0) sr.push_back(mp(0.0, id)); for (auto &[w, i] : edge[id]) { if (b[i]) continue; DFS(i); } } double DIJKSTRA() { fill(dis + 1, dis + n + 1, INF); for (auto &i : sr) pq.push(i); while (pq.size()) { auto [len, id] = pq.top(); pq.pop(); if (dis[id] < INF) continue; dis[id] = len; for (auto &[w, i] : edge[id]) { if (dis[i] < INF) continue; pq.push(mp(w + len, i)); } } return dis[h]; } double miku() { FOR(i, 0, m) { edge[x[i]].push_back(mp((double) c[i], y[i])); edge[y[i]].push_back(mp((double) c[i], x[i])); } ans = INF; sr.push_back(mp(0.0, 1)); DFS(1); // for (auto &[_, i] : sr) debug(i); while (k--) { ans = min(ans, DIJKSTRA()); sr.clear(); FOR(i, 1, n + 1) if (b[i] && s[i] == 2) sr.push_back(mp(dis[i] / 2.0, i)); } DIJKSTRA(); ans = min(ans, DIJKSTRA()); return ans; } void RESET() { FOR(i, 1, n + 1) { edge[i].clear(); b[i] = false; } } } double solve(int N, int M, int K, int H, vector<int> X, vector<int> Y, vector<int> C, vector<int> S) { H++; for (auto &i : X) i++; for (auto &i : Y) i++; S.insert(S.begin(), 0); ::n = N; ::m = M; ::k = K; ::h = H; ::x = X; ::y = Y; ::c = C; ::s = S; double ans = miku(); RESET(); return (ans == ::INF ? -1.0 : ans); } #ifdef MIKU int32_t main() { cin.tie(0) -> sync_with_stdio(false); cin.exceptions(cin.failbit); int n, m, k, h; vector<int> x, y, c, s; cin >> n >> m >> k >> h; x.resize(m); y.resize(m); c.resize(m); s.resize(n); for (auto &i : s) cin >> i; FOR(i, 0, m) cin >> x[i] >> y[i] >> c[i]; double d = solve(n, m, k, h, x, y, c, s); cout << d << '\n'; return 0; } #endif

컴파일 시 표준 에러 (stderr) 메시지

cyberland.cpp: In function 'void {anonymous}::DFS(int)':
cyberland.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
cyberland.cpp:33:9: note: in expansion of macro 'debug'
   33 |         debug(id);
      |         ^~~~~
#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...