Submission #719842

#TimeUsernameProblemLanguageResultExecution timeMemory
719842JuanCommuter Pass (JOI18_commuter_pass)C++14
0 / 100
459 ms28084 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define tii tuple<int, int, int> #define pii pair<int, int> #define ff first #define ss second const int maxn = 1e5 + 5, INF = 0x3f3f3f3f3f3f3f3f; vector<pii> adj[maxn]; vector<int> g[maxn]; vector<tii> edges; int n; vector<int> dijkstra(int ini){ priority_queue<pii, vector<pii>, greater<pii>> pq; vector<int> dist(n+1, INF); dist[ini] = 0; pq.push({0, ini}); while(pq.size()){ auto[d, u] = pq.top(); pq.pop(); if(d > dist[u]) continue; for(int v : g[u]) if(dist[u] < dist[v]){ dist[v] = dist[u]; pq.push({dist[u], v}); } for(auto [v, w] : adj[u]) if(dist[u]+w < dist[v]){ dist[v] = dist[u] + w; pq.push({dist[u]+w, v}); } } return dist; } int32_t main(){ int m; cin >> n >> m; int S, T; cin >> S >> T; int U, V; cin >> U >> V; for(int i = 0; i < m; i++){ int a, b, c; cin >> a >> b >> c; adj[a].push_back({b, c}); adj[b].push_back({a, c}); edges.push_back({a, b, c}); } vector<int> distS = dijkstra(S), distT = dijkstra(T); int minpath = distS[T]; for(auto[a, b, c] : edges) if(distS[a] < distS[b]){ if(distS[a]+c+distT[b] == minpath) g[a].push_back(b); } vector<int> dist1 = dijkstra(U); int ans = dist1[V]; for(int i = 1; i <= n; i++) g[i].clear(); for(auto[a, b, c] : edges) if(distS[a] < distS[b]){ if(distS[a]+c+distT[b] == minpath) g[b].push_back(a); } vector<int> dist2 = dijkstra(U); ans = min(ans, dist2[V]); cout << ans << '\n'; }

Compilation message (stderr)

commuter_pass.cpp: In function 'std::vector<long long int> dijkstra(long long int)':
commuter_pass.cpp:22:7: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |   auto[d, u] = pq.top();
      |       ^
commuter_pass.cpp:31:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |   for(auto [v, w] : adj[u]) if(dist[u]+w < dist[v]){
      |            ^
commuter_pass.cpp: In function 'int32_t main()':
commuter_pass.cpp:54:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   54 |  for(auto[a, b, c] : edges) if(distS[a] < distS[b]){
      |          ^
commuter_pass.cpp:61:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   61 |  for(auto[a, b, c] : edges) if(distS[a] < distS[b]){
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...