# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
968804 | 2024-04-24T06:17:15 Z | blackslex | Cities (BOI16_cities) | C++17 | 313 ms | 23108 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; int n, m, k, x, y; ll z; int main() { scanf("%d %d %d", &n, &k, &m); vector<int> c(k); vector<vector<pii>> v(n + 5, vector<pii>()); for (auto &e: c) scanf("%d", &e); while (m--) scanf("%d %d %lld", &x, &y, &z), v[x].emplace_back(y, z), v[y].emplace_back(x, z); vector<vector<ll>> d(k, vector<ll>(n + 5, 1e18)); auto dijk = [&] (int st, vector<ll> &curd) { priority_queue<pii, vector<pii>, greater<pii>> pq; pq.emplace(curd[st] = 0, st); while (!pq.empty()) { auto [nd, nn] = pq.top(); pq.pop(); for (auto &[tn, td]: v[nn]) if (curd[tn] > curd[nn] + td) pq.emplace(curd[tn] = curd[nn] + td, tn); } }; for (int i = 0; i < k; i++) dijk(c[i], d[i]); ll ans = 1e18; for (int i = 1; i <= n; i++) { ll cur = 0; for (int j = 0; j < k; j++) cur += d[j][i]; ans = min(ans, cur); } printf("%lld", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 1 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 176 ms | 21596 KB | Output is correct |
2 | Correct | 218 ms | 22024 KB | Output is correct |
3 | Correct | 90 ms | 13040 KB | Output is correct |
4 | Correct | 66 ms | 13116 KB | Output is correct |
5 | Correct | 190 ms | 20768 KB | Output is correct |
6 | Correct | 61 ms | 13136 KB | Output is correct |
7 | Correct | 2 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 297 ms | 22520 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 313 ms | 23108 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |