Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T> inline T sqr(T t) {return t*t;}
#define pb push_back
#define mp make_pair
#define endl "\n"

inline void files()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef _WIN32
        return;
    #endif // _WIN32
    //freopen("C.in", "r", stdin);freopen("C.out", "w", stdout);
}

int d[300][300];

int n, m, r, a[100100];

int mn = 1e9;

int used[100100];

bool taken[100100];

void rec(int sz){
    if (sz == r){
        ll ans = 0;
        for (int i = 2; i <= r; i++)
            ans += d[used[i-1]][used[i]];
        mn = min(ans, mn);

        return;
    }
    for (int j = 1; j <= r; j++)
        if (!taken[j]){
            used[sz+1] = a[j];
            taken[j] = 1;
            rec(sz+1);
            taken[j] = 0;
        }
}

int main(){
    files();
    cin >> n >> m >> r;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++){
            d[i][j] = 1e9;
            if (i==j)
                d[i][j] = 0;
        }
    for (int i = 1; i <= r; i++)
        cin >> a[i];
    for (int i = 1; i <= m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
    }
    for (int k = 1; k <= n; k++){
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
    }
    rec(0);
    cout << mn;
}


Compiler output:
a.cc: In function 'void rec(int)':
a.cc:34:17: error: no matching function for call to 'min(ll&, int&)'
   34 |         mn = min(ans, mn);
      |              ~~~^~~~~~~~~
In file included 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_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:34:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   34 |         mn = min(ans, mn);
      |              ~~~^~~~~~~~~
/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:
/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:34:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |         mn = min(ans, mn);
      |              ~~~^~~~~~~~~