Language: C++

#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
using namespace std;
typedef pair<int,int>P;
const int N = 205;
const int INF = 1e7;
struct edg{
    int to,cost;
};
int vis[N];
int d[N];
int prev[N];
vector<edg>g[N];
vector<int>path;
void get(int t)
{
    for(;t!=-1;t=prev[t]) path.push_back(t);
    reverse(path.begin(),path.end());
}
int r[N];
void dij(int s)
{

    priority_queue<P, vector<P>, greater<P> >que;
    fill(d,d+N,INF);
    fill(prev,prev+N,-1);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty())
    {
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        int cnt=g[v].size();
        for(int i=0;i<cnt;i++)
        {
            edg e=g[v][i];
            if(d[e.to]>d[v]+e.cost)
            {
                d[e.to]=d[v]+e.cost;
                prev[e.to]=v;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
int main()
{
    int n,m,R;
    int u,v,c;
    memset(vis,0,sizeof(vis));
    scanf("%d%d%d",&n,&m,&R);
    for(int i=1;i<=R;i++)
    {
        scanf("%d",&r[i]);
    }
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&u,&v,&c);
        edg x;
        x.to=v;x.cost=c;
        g[u].push_back(x);
        x.to=u;
        g[v].push_back(x);
    }
    long long ans=0;
    dij(r[1]);
    vis[r[1]]=1;
    for(int i=2;i<=R;i++)
    {
        de(vis[r[i]]);
        if(vis[r[i]]>=2) {ans-=d[r[i]];continue;}
        else if(vis[r[i]]==1) continue;
       ans+=d[r[i]];
        get(r[i]);
        int cnt=path.size();
       // cout<<"-------\n";
        for(i=0;i<cnt-1;i++)
        {
          //  cout<<path[i]<<endl;
             vis[path[i]]++;
        }
    }
    //cout<<"-----"<<endl;
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'void get(int)':
a.cc:17:18: error: reference to 'prev' is ambiguous
   17 |     for(;t!=-1;t=prev[t]) path.push_back(t);
      |                  ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:5: note:                 'int prev [205]'
   12 | int prev[N];
      |     ^~~~
a.cc: In function 'void dij(int)':
a.cc:26:10: error: reference to 'prev' is ambiguous
   26 |     fill(prev,prev+N,-1);
      |          ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:5: note:                 'int prev [205]'
   12 | int prev[N];
      |     ^~~~
a.cc:26:15: error: reference to 'prev' is ambiguous
   26 |     fill(prev,prev+N,-1);
      |               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:5: note:                 'int prev [205]'
   12 | int prev[N];
      |     ^~~~
a.cc:41:17: error: reference to 'prev' is ambiguous
   41 |                 prev[e.to]=v;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:5: note:                 'int prev [205]'
   12 | int prev[N];
      |     ^~~~