Language: C++

#include <bits/stdc++.h>
#define INF 1000000000000007
#define MAX_N 200
using namespace std;

long d[MAX_N + 1][MAX_N + 1];

void warshall_floyd(int n) {
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

long dfs(long r[], int n, int start, short bit_set) {
    if (n == 0)
        return 0;
    int i = 0, ret = INF;
    short b = bit_set;
    while (b > 0) {
        if (b & 1)
            ret = min(ret, d[start][r[i]] + dfs(r, n - 1, r[i], bit_set ^ (1 << i)));
        i++;
        b >>= 1;
    }
    return ret;
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    long r[R];
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            d[i][j] = INF;
        }
    }
    for (int i = 0; i < R; i++) {
        cin >> r[i];
    }
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyd(N);
    long ans = INF;
    for (int i = 0; i < R; i++) {
        ans = min(ans, dfs(r, R - 1, r[i], ((1 << R) - 1) ^ (1 << i)));
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'long int dfs(long int*, int, int, short int)':
a.cc:2:13: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000007' to '-1530494969' [-Woverflow]
    2 | #define INF 1000000000000007
      |             ^~~~~~~~~~~~~~~~
a.cc:21:22: note: in expansion of macro 'INF'
   21 |     int i = 0, ret = INF;
      |                      ^~~
a.cc:25:22: error: no matching function for call to 'min(int&, long int)'
   25 |             ret = min(ret, d[start][r[i]] + dfs(r, n - 1, r[i], bit_set ^ (1 << i)));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:25:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   25 |             ret = min(ret, d[start][r[i]] + dfs(r, n - 1, r[i], bit_set ^ (1 << i)));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:25:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |             ret = min(ret, d[start][r[i]] + dfs(r, n - 1, r[i], bit_set ^ (1 << i)));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~