Submission #945649

#TimeUsernameProblemLanguageResultExecution timeMemory
945649ezzzayCommuter Pass (JOI18_commuter_pass)C++14
0 / 100
288 ms262144 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=2e5+5; vector<pair<int,int>>v[N]; int dist[N]; int tmp[N]; int par[N]; vector<pair<int,int>>vc; signed main(){ int n,m,s,t,x,y; cin>>n>>m>>s>>t>>x>>y; for(int i=0;i<m;i++){ int a,b,c; cin>>a>>b>>c; v[a].pb({b,c}); v[b].pb({a,c}); } for(int i=1;i<=n;i++){ dist[i]=1e9; } priority_queue<pair<int,int>>q; q.push({0,s}); par[s]=s; dist[s]=0; while(!q.empty()){ int w=-q.top().ff; int a=q.top().ss; q.pop(); if(dist[a]<w)continue; for(auto p:v[a]){ int b=p.ff; int c=p.ss; if(dist[a]+c<dist[b]){ dist[b]=dist[a]+c; par[b]=a; q.push({-dist[b],b}); } } } while(t!=s){ v[t].pb({par[t],0}); v[par[t]].pb({t,0}); t=par[t]; } for(int i=1;i<=n;i++){ dist[i]=1e9; } s=x; q.push({0,s}); par[s]=s; dist[s]=0; while(!q.empty()){ int w=-q.top().ff; int a=q.top().ss; q.pop(); if(dist[a]<w)continue; for(auto p:v[a]){ int b=p.ff; int c=p.ss; if(dist[a]+c<dist[b]){ dist[b]=dist[a]+c; par[b]=a; q.push({-dist[b],b}); } } } cout<<dist[y]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...