Language: C++

#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int adj[205][205],sum;
int n,r,m;
vector<int>place;
bool visit[500];
void dfs(int src,int cur,int tot)
{
    visit[src]=1;
    int f=0;
    priority_queue<pair<int,int> >pq;
    for(int i=0; i<r; i++)
    {
        int child=place[i];
        if(visit[child]==0)
            pq.push({adj[src][child]*-1,child});
    }
    if(tot==r)
    {
        sum=min(cur,sum);
    }
    while(!pq.empty())
    {
        int child=pq.top().second;
        int cost=pq.top().first*-1;
        pq.pop();
        dfs(child,cur+cost,tot+1);
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n>>m>>r;
    for(int i=0; i<r; i++)
    {
        int a;
        cin>>a;
        place.push_back(a);
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
         adj[i][j]=1e8;
    while(m--)
    {
        int u,v,c;
        cin>>u>>v>>c;
        adj[u][v]=c;
        adj[v][u]=c;
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                adj[i][j]=min(adj[i][j],adj[i][k]+adj[k][j]);
            }
        }
    }
    sum=INT_MAX;
    for(int i=0; i<r; i++)
    {
        dfs(place[i],0,1);
        for(int j=0; j<=n; j++)
            visit[j]=0;
    }
    cout<<sum<<endl;



    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:21:5: error: reference to 'visit' is ambiguous
   21 |     visit[src]=1;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:18:6: note:                 'bool visit [500]'
   18 | bool visit[500];
      |      ^~~~~
a.cc:27:12: error: reference to 'visit' is ambiguous
   27 |         if(visit[child]==0)
      |            ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:18:6: note:                 'bool visit [500]'
   18 | bool visit[500];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:75:13: error: reference to 'visit' is ambiguous
   75 |             visit[j]=0;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:18:6: note:                 'bool visit [500]'
   18 | bool visit[500];
      |      ^~~~~