#include <bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0);
typedef long long LL;
typedef pair<int,int> PII;

const int N=2e6+10, INF=0x3f3f3f3f;
int n, m, q;
int h[N], e[N], ne[N], idx;
int w[N];//存权重
int d[N];
bool st[N];//标记是否已经确定最短路径
void add(int a,int b,int c)
{
    e[idx]=b, w[idx]=c, ne[idx]=h[a], h[a]=idx++;
}
void dijkstra()
{
    memset(d, 0x3f, sizeof d);
    d[1]=0;
    priority_queue<PII, vector<PII>, greater<PII> > q;
    q.push({0, 1});
    while(q.size())
    {
        auto [dist, ver]=q.top();
        q.pop();

        if(st[ver]) continue;
        st[ver]=1;

        for(int i=h[ver]; i!=-1; i=ne[i]){
            int j=e[i];
            if(d[j]>dist+w[i]){
                d[j]=dist+w[i];
                q.push({d[j], j});
            }
        }
    }
}
int main()
{
    IOS
    memset(h, -1, sizeof h);
    cin>>n>>m>>q;
    int a, b, c;
    for(int i=0; i<m; i++){
        cin>>a>>b>>c;
        add(a, b, c); add(b, a, c);
    }
    dijkstra();
    LL ans=0;
    for(int i=1; i<=q; i++){
        cin>>a;
        ans+=2*d[a];
    }
    cout<<ans;
    return 0;
}

注意题目里小红每次只送一份外卖,也就是要来回两次,每次送外卖互不影响。

dij求单源最短路后,ans+=d[q]*2即可

ans怕爆int,就无脑开ll了

#牛客春招刷题训练营#