제출 #41163

#제출 시각아이디문제언어결과실행 시간메모리
41163ngkan146Commuter Pass (JOI18_commuter_pass)C++98
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; struct edge{ int v, w; edge(int v=0,int w=0): v(v), w(w) {} }; int n,m,s,t,u,v; vector <edge> G[100005]; vector <int> dag[100005]; ll dis[100005], disS[100005], disU[100005], disV[100005]; bool visited[100005]; priority_queue <pair<long long,int>, vector<pair<long long,int> >, greater<pair<long long, int> > > pq; void dijkstra(int root){ fill(dis+1,dis+n+1, (ll) 1e18); fill(visited,visited+n+1,0); dis[root] = 0; pq.push(pair<ll,int>(0ll, root)); while(pq.size()){ int u = pq.top().second; pq.pop(); if (visited[u]) continue; visited[u] = 1; for(auto v: G[u]){ if (dis[v.v] > dis[u] + v.w) dis[v.v] = dis[u] + v.w, pq.push(pair<ll,int>(dis[v.v], v.v)); } } } void trailBack(int u){ if (visited[u]) return; visited[u] = 1; for(auto v: G[u]){ if (disS[v.v] == disS[u] - v.w) dag[v.v].push_back(u), trailBack(v.v); } } ll ans = (ll) 1e18; ll dfs(int u){ ll mini = (ll) disV[u]; for(int v: dag[u]){ mini = min(mini, dfs(v)); } ans = min(ans, disU[u] + mini); return mini; } int main(){ iostream::sync_with_stdio(0); cin >> n >> m >> s >> t >> u >> v; for(int i=1;i<=m;i++){ int a,b,c; cin >> a >> b >> c; G[a].push_back(edge(b, c)); G[b].push_back(edge(a, c)); } dijkstra(s); for(int i=1;i<=n;i++) disS[i] = dis[i]; fill(visited+1,visited+n+1,0); trailBack(t); dijkstra(u); for(int i=1;i<=n;i++) disU[i] = dis[i]; ans = disU[v]; dijkstra(v); for(int i=1;i<=n;i++) disV[i] = dis[i]; dfs(s); swap(disU, disV); dfs(s); cout << ans; }

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

commuter_pass.cpp: In function 'void dijkstra(int)':
commuter_pass.cpp:24:13: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
         for(auto v: G[u]){
             ^
commuter_pass.cpp:24:18: error: 'v' does not name a type
         for(auto v: G[u]){
                  ^
commuter_pass.cpp:29:5: error: expected ';' before '}' token
     }
     ^
commuter_pass.cpp:29:5: error: expected primary-expression before '}' token
commuter_pass.cpp:29:5: error: expected ';' before '}' token
commuter_pass.cpp:29:5: error: expected primary-expression before '}' token
commuter_pass.cpp:29:5: error: expected ')' before '}' token
commuter_pass.cpp:29:5: error: expected primary-expression before '}' token
commuter_pass.cpp: In function 'void trailBack(int)':
commuter_pass.cpp:34:9: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
     for(auto v: G[u]){
         ^
commuter_pass.cpp:34:14: error: 'v' does not name a type
     for(auto v: G[u]){
              ^
commuter_pass.cpp:39:1: error: expected ';' before '}' token
 }
 ^
commuter_pass.cpp:39:1: error: expected primary-expression before '}' token
commuter_pass.cpp:39:1: error: expected ';' before '}' token
commuter_pass.cpp:39:1: error: expected primary-expression before '}' token
commuter_pass.cpp:39:1: error: expected ')' before '}' token
commuter_pass.cpp:39:1: error: expected primary-expression before '}' token
commuter_pass.cpp: In function 'long long int dfs(int)':
commuter_pass.cpp:43:16: warning: range-based 'for' loops only available with -std=c++11 or -std=gnu++11
     for(int v: dag[u]){
                ^