제출 #968804

#제출 시각아이디문제언어결과실행 시간메모리
968804blackslexCities (BOI16_cities)C++17
14 / 100
313 ms23108 KiB
#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); }

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

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 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...