| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1167741 | mareksb | Commuter Pass (JOI18_commuter_pass) | C++20 | 0 ms | 0 KiB | 
#include <bits/stdc++.h>
#pragma GCC optimize ("O3,unroll-loops")
#pragma GCC target ("avx2,bmi,bmi2,popcnt,lzcnt")
using namespace std;
const int64_t N=100005;
vector<pair<int64_t,int64_t>> mas[N];
int64_t dS[N];
int64_t dT[N];
int64_t dV[N];
int64_t dU[N];
int64_t n,m;
int64_t s,t;//commuter pass
int64_t u,v;
void dijkstra(int64_t start, int64_t* dist){
    priority_queue<pair<int64_t,int64_t>,vector<pair<int64_t,int64_t>>,greater<pair<int64_t,int64_t>>> pq;
    dist[start]=0;
    pq.push({0,start});
    while(!pq.empty()){
        int64_t x=pq.top().second;
        pq.pop();
        for(auto p:mas[x]){
            if(dist[x]+p.second<dist[p.first]){
                dist[p.first]=dist[x]+p.second;
                pq.push({dist[p.first],p.first});
            }
        }
    }
}
using data=pair<int,int>;
void dijkstra2(int64_t start, int64_t* dist){
    priority_queue<data,vector<data>,greater<data>> pq;
    dist[start]=0;
    pq.push({0,start});
    while(!pq.empty()){
        int64_t x=pq.top().second;
        pq.pop();
        for(auto p:mas[x]){
            int64_t cost=p.second;
            if(dS[x]+dT[x]==dS[t]&&dS[p.first]+dT[p.first]==dS[t]){
                cost=0;
            }
            if(dist[x]+cost<dist[p.first]){
                dist[p.first]=dist[x]+cost;
                pq.push({dist[p.first],p.first});
            }
        }
    }
}
int64_t df[305][305];
void floyd(){
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                df[i][j]=min(df[i][j],df[i][k]+df[k][j]);
            }
        }
    }
}
bool vis[N];
int64_t dpX[N];//best distance from x to v
void dfs(int v){
    vis[v]=1;
    int64_t best=LLONG_MAX;
    cout<<"lookup:"<<v<<'\n';
    for(auto p:mas[v]){
        int u=p.first;
        int c=p.second;
        if(vis[u]==1||dS[u]+dT[u]!=dS[t])continue;
        dfs(u);
        best=min(best,dpX[u]);
    }
    dpX[v]=min(dV[v],best);
}
void solve(){
    cin>>n>>m;
    for(int64_t i=0;i<=n;i++){
        dS[i]=LLONG_MAX/4;
        dT[i]=LLONG_MAX/4;
        dV[i]=LLONG_MAX/4;
        dU[i]=LLONG_MAX/4;
        dpX[i]=LLONG_MAX/4;
    }
    cin>>s>>t;
    cin>>u>>v;
    for(int64_t i=0;i<m;i++){
        int64_t x,y,c;
        cin>>x>>y>>c;
        mas[x].push_back({y,c});
        mas[y].push_back({x,c});
        df[x][y]=c;
        df[y][x]=c;
    }
    dijkstra(s,dS);
    dijkstra(t,dT);
    dijkstra(u,dU);
    dijkstra(v,dV);
    dfs(s);
    int64_t ans=dU[v];
    cout<<"0: "<<ans<<'\n';
    for(int x=1;x<=n;x++){
        //1 should be 15
        ans=min(ans,dU[x]+dpX[x]);
        cout<<x<<": "<<ans<<'\n';
    }
    cout<<ans<<'\n';
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
    int64_t t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
