Language: C++

#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>

using namespace std;

int path[201][201];


int main(int argc, char *argv[]) {
	int N, M, R;
	cin >> N >> M >> R;

	vector<int> r;
	for (int i = 0; i < R; i++) {
		int ri;
		cin >> ri;
		r.push_back(ri);
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (i != j) path[i][j] = 1000000;
		}
	}

	for (int i = 0; i < M; i++) {
		int A, B, C;
		cin >> A >> B >> C;
		path[A][B] = path[B][A] = C;
	}

	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				if (path[i][j] > path[i][k] + path[k][j]) {
					path[i][j] = path[i][k] + path[k][j];
				}
			}
		}
	}

	sort(r.begin(), r.end());

	int ans = numeric_limits<int>::max();
	do {
		long long d = 0;
		for (int i = 1; i < r.size(); i++) {
			d += path[r[i-1]][r[i]];
		}
		ans = min(ans, d);
	} while(next_permutation(r.begin(), r.end()));

	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:52:26: error: no matching function for call to 'min(int&, long long int&)'
   52 |                 ans = min(ans, d);
      |                       ~~~^~~~~~~~
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: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:52:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   52 |                 ans = min(ans, d);
      |                       ~~~^~~~~~~~
/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:4:
/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:52:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |                 ans = min(ans, d);
      |                       ~~~^~~~~~~~