Language: C++

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
long long g[205][205];
int index[205];
void floyd(int n)
{
    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                g[i][j]=min(g[i][k]+g[k][j],g[i][j]);
            }
        }
    }
    return ;
}
int main()
{
    int n,m,r;
    cin>>n>>m>>r;
    for(int i=1;i<=r;i++)
        cin>>index[i];
    sort(index+1,index+1+r);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j) g[i][j]=0;
            else g[i][j]=100005;
        }
    }
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        scanf("%d %d %d",&x,&y,&z);
        g[x][y]=min(z,g[x][y]);
        g[y][x]=min(z,g[y][x]);
    }
    floyd(n);
    long long ans=100000005;
    do
    {
        long long sum=0;
        for(int i=1;i<=r-1;i++)
        {
            //cout<<index[i]<<" "<<index[i+1]<<" "<<g[index[i]][index[i+1]]<<endl;
            sum+=g[index[i]][index[i+1]];
        }
        ans=min(ans,sum);
    }while(next_permutation(index+1,index+1+r));
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:6:5: warning: built-in function 'index' declared as non-function [-Wbuiltin-declaration-mismatch]
    6 | int index[205];
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:40:20: error: no matching function for call to 'min(int&, long long int&)'
   40 |         g[x][y]=min(z,g[x][y]);
      |                 ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:40:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   40 |         g[x][y]=min(z,g[x][y]);
      |                 ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:40:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |         g[x][y]=min(z,g[x][y]);
      |                 ~~~^~~~~~~~~~~
a.cc:41:20: error: no matching function for call to 'min(int&, long long int&)'
   41 |         g[y][x]=min(z,g[y][x]);
      |                 ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:41:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   41 |         g[y][x]=min(z,g[y][x]);
      |                 ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:41:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |         g[y][x]=min(z,g[y][x]);
      |                 ~~~^~~~~~~~~~~