제출 #996360

#제출 시각아이디문제언어결과실행 시간메모리
996360yanbCommuter Pass (JOI18_commuter_pass)C++14
15 / 100
335 ms26312 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<long long, long long> #define t3i tuple<long long, long long, long long> int n, m, S, T, U, V; vector<vector<pii>> g; vector<int> halt() { priority_queue<t3i, vector<t3i>, greater<t3i>> q; q.push({0, S, -1}); vector<int> d(n, 1e17), prev(n); while (!q.empty()) { auto [dv, v, par] = q.top(); q.pop(); if (d[v] <= dv) continue; d[v] = dv; prev[v] = par; for (auto [c, u] : g[v]) { q.push({dv + c, u, v}); } } vector<int> hal; int t = T; while (t != -1) { hal.push_back(t); t = prev[t]; } return hal; } int bfs(int v, vector<int> &goal) { priority_queue<pii, vector<pii>, greater<pii>> q; q.push({0, v}); vector<int> d(n, 1e17); while (!q.empty()) { auto [dv, v] = q.top(); q.pop(); if (d[v] <= dv) continue; d[v] = dv; for (auto [c, u] : g[v]) { q.push({dv + c, u}); } } int ans = 1e17; for (int x : goal) { ans = min(ans, d[x]); } return ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> S >> T >> U >> V; S--, T--, U--, V--; g.resize(n); for (int i = 0; i < m; i++) { int x, y, c; cin >> x >> y >> c; x--; y--; g[x].push_back({c, y}); g[y].push_back({c, x}); } vector<int> hal = halt(), uvec(1, U); cout << min(bfs(U, hal) + bfs(V, hal), bfs(V, uvec)) << "\n"; }

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

commuter_pass.cpp: In function 'std::vector<long long int> halt()':
commuter_pass.cpp:18:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   18 |         auto [dv, v, par] = q.top();
      |              ^
commuter_pass.cpp:24:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   24 |         for (auto [c, u] : g[v]) {
      |                   ^
commuter_pass.cpp: In function 'long long int bfs(long long int, std::vector<long long int>&)':
commuter_pass.cpp:45:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   45 |         auto [dv, v] = q.top();
      |              ^
commuter_pass.cpp:50:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   50 |         for (auto [c, u] : g[v]) {
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...