Submission #937253

#TimeUsernameProblemLanguageResultExecution timeMemory
937253Marco_EscandonCommuter Pass (JOI18_commuter_pass)C++11
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define x first #define y second vector<vector<ll>> v(5,vector<ll>(100001,1e16)); vector<vector<pair<ll,ll>>>G1(100001); vector<vector<ll>>G2(100001); void dijkstra(ll pl, ll node) { priority_queue<pair<ll,ll>> q; q.push({0,node}); while(!q.empty()) { pair<ll,ll> a=q.top();q.pop(); if(v[pl][a.y]==1e16) { v[pl][a.y]=-a.x; for(auto i:G1[a.y]) if(v[pl][i.x]==1e16) q.push({a.x-i.y,i.x}); } } } pair<ll,pair<ll,ll>> dp(n,{-1,{0,0}}); pair<ll,pair<ll,ll>> dfs(ll node, ll padre) { if(dp[node].first!=-1) return dp[node]; pair<ll,pair<ll,ll>> sol={v[2][node]+v[3][node],{v[2][node],v[3][node]}}; for(auto i:G2[node]) { if(i!=padre) { pair<ll,pair<ll,ll>> temp=dfs(i,node); sol.x=min(sol.x,temp.x); sol.x=min(sol.x,v[2][node]+temp.y.y); sol.x=min(sol.x,v[3][node]+temp.y.x); sol.y.x=min(sol.y.x,temp.y.x); sol.y.y=min(sol.y.y,temp.y.y); } } return dp[node]=sol; } int main() { ll n,m; cin>>n>>m; ll s,t,u,w; cin>>s>>t>>u>>w; for(int i=0; i<m; i++) { ll a,b,c; cin>>a>>b>>c; G1[a].push_back({b,c}); G1[b].push_back({a,c}); } dijkstra(0,s); dijkstra(1,t); dijkstra(2,u); dijkstra(3,w); for(int i=1; i<=n; i++) for(auto j:G1[i]) if(v[0][i]+v[1][j.x]+j.y==v[0][t]) G2[i].push_back(j.x); cout<<min(dfs(s,0).x,v[2][w]); }

Compilation message (stderr)

commuter_pass.cpp:25:25: error: 'n' was not declared in this scope
   25 | pair<ll,pair<ll,ll>> dp(n,{-1,{0,0}});
      |                         ^
commuter_pass.cpp: In function 'std::pair<long long int, std::pair<long long int, long long int> > dfs(ll, ll)':
commuter_pass.cpp:28:10: error: no match for 'operator[]' (operand types are 'std::pair<long long int, std::pair<long long int, long long int> >' and 'll' {aka 'long long int'})
   28 |     if(dp[node].first!=-1)
      |          ^
commuter_pass.cpp:29:18: error: no match for 'operator[]' (operand types are 'std::pair<long long int, std::pair<long long int, long long int> >' and 'll' {aka 'long long int'})
   29 |         return dp[node];
      |                  ^
commuter_pass.cpp:43:14: error: no match for 'operator[]' (operand types are 'std::pair<long long int, std::pair<long long int, long long int> >' and 'll' {aka 'long long int'})
   43 |     return dp[node]=sol;
      |              ^