Submission #375720

#TimeUsernameProblemLanguageResultExecution timeMemory
375720iliccmarkoCommuter Pass (JOI18_commuter_pass)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define INF 1000000000 #define LINF 1000000000000000LL #define pb push_back #define all(x) x.begin(), x.end() #define len(s) (int)s.size() #define test_case { int t; cin>>t; while(t--)solve(); } #define single_case solve(); #define line cerr<<"----------"<<endl; #define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); } #define mod 1000000007LL int n, m, s, t, u, v; const int N = 1e5 + 50; vector<pair<int, ll> > g[N]; vector<int> dag[N]; ll dpu[N], dpv[N]; ll diss[N], disv[N], dist[N], disu[N]; int vidjen[N]; void dijkstra(int src, ll dis[]) { for(int i = 0;i<N;i++) dis[i] = LINF, vidjen[i] = 0; dis[src] = 0; priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > pq; pq.push(make_pair(0, src)); while(len(pq)) { int u = pq.top().second; pq.pop(); if(vidjen[u]) continue; vidjen[u] = 1; for(auto x : g[u]) { if(dis[x.first]>dis[u]+x.second) { dis[x.first] = dis[u] + x.second; pq.push(make_pair(dis[x.first], x.first)); } } } } ll dfs(int u, ll d[], ll dp[]) { dp[u] = d[u]; vidjen[u] = 1; for(auto x : dag[u]) { if(vidjen[x.first]) { dp[u] = min(dp[u], dp[x.first]); continue; } dp[u] = min(dp[u], dfs(x, d, dp)); } return dp[u]; } int main() { ios for(int i = 0;i<N;i++) dpu[i] = dpv[i] = LINF; cin>>n>>m>>s>>t>>u>>v; for(int i = 0;i<m;i++) { int a, b, c; cin>>a>>b>>c; g[a].pb(make_pair(b, c)); g[b].pb(make_pair(a, c)); } dijkstra(s, diss); dijkstra(t, dist); dijkstra(u, disu); dijkstra(v, disv); ll res = disu[v]; for(int i = 1;i<=n;i++) { for(auto x : g[i]) { if(diss[i]+x.second+dist[x.first]==diss[t]) { dag[i].pb(x.first); } } } dfs(s, disu, dpu); for(int i = 1;i<=n;i++) { res = min(res, dpu[i]+disv[i]); } dfs(s, disv, dpv); for(int i = 1;i<=n;i++) { res = min(res, dpv[i]+disu[i]); } cout<<res; return 0; }

Compilation message (stderr)

commuter_pass.cpp: In function 'long long int dfs(int, long long int*, long long int*)':
commuter_pass.cpp:52:21: error: request for member 'first' in 'x', which is of non-class type 'int'
   52 |         if(vidjen[x.first])
      |                     ^~~~~
commuter_pass.cpp:54:37: error: request for member 'first' in 'x', which is of non-class type 'int'
   54 |             dp[u] = min(dp[u], dp[x.first]);
      |                                     ^~~~~