Submission #968804

# Submission time Handle Problem Language Result Execution time Memory
968804 2024-04-24T06:17:15 Z blackslex Cities (BOI16_cities) C++17
14 / 100
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

cities.cpp: In function 'int main()':
cities.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %d %d", &n, &k, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
cities.cpp:14:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for (auto &e: c) scanf("%d", &e);
      |                      ~~~~~^~~~~~~~~~
cities.cpp:15:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     while (m--) scanf("%d %d %lld", &x, &y, &z), v[x].emplace_back(y, z), v[y].emplace_back(x, z);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 297 ms 22520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 313 ms 23108 KB Output isn't correct
2 Halted 0 ms 0 KB -