Submission #869354

#TimeUsernameProblemLanguageResultExecution timeMemory
869354vjudge1Commuter Pass (JOI18_commuter_pass)C++17
0 / 100
421 ms22040 KiB
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second #define ll long long int const int mxn=1e5+5; ll n,m,dis[2][mxn],s,t,u,v,par[2][mxn],ans=1e18; vector<pair<int,int> >yal[mxn]; set<pair<ll,ll> >st; void dij(int r,int f){ for(int i=1;i<=n;i++){ dis[f][i]=(i==r)?0:1e18; st.insert({dis[f][i],i}); } while(st.size()){ auto x=*st.begin(); st.erase({x.fr,x.sc}); //cout<<x.sc<<" "<<par[f][x.sc]<<endl; for(auto i:yal[x.sc]){ if(dis[f][i.fr]>x.fr+i.sc){ st.erase({dis[f][i.fr],i.fr}); dis[f][i.fr]=x.fr+i.sc; st.insert({dis[f][i.fr],i.fr}); par[f][i.fr]=x.sc; } } } } int main(){ cin>>n>>m; cin>>s>>t>>u>>v; for(int i=1;i<=m;i++){ int x,y,w; cin>>x>>y>>w; yal[x].push_back({y,w}); yal[y].push_back({x,w}); } dij(s,0); //cout<<endl; dij(v,1); for(int x=t;x!=0;x=par[0][x]){ //cout<<x<<" "; ans=min(ans,dis[1][x]); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...