Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int M, N, D; long long int K; cin >> M >> N >> K >> D;
		if (!M)break;
		vector<int>cs(M);
		for (int i = 0; i < M; ++i) {
			cin >> cs[i];
		}
		const int land = 0;
		const int start = land+N;
		const int goal = start + 1;
		const int cake = goal + 1;
		vector<vector<int>>diss(cake+M, vector<int>(cake+M, 1e6));
		for (int i = 0; i < diss.size(); ++i) {
			diss[i][i] = 0;
		}
		for (int i = 0; i < D; ++i) {
			string f[2]; cin >> f[0] >> f[1];
			int from[2];
			for (int j = 0; j < 2; ++j) {
				if (f[j] == "H")from[j] = start;
				if (f[j] == "D")from[j] = goal;
				if (f[j][0] == 'C')from[j] = cake + f[j][1] - '1';
				if (f[j][0] == 'L')from[j] = land + f[j][1] - '1';
			}
			int d; cin >> d;
			diss[from[0]][from[1]] = d;
			diss[from[1]][from[0]] = d;
		}
		for (int k = 0; k <= goal; ++k) {
			for (int i = 0; i <= goal; ++i) {
				for (int j = 0; j <= goal; ++j) {
					diss[i][j] = min(diss[i][j], diss[i][k] + diss[k][j]);
				}
			}
		}
		for (int i = 0; i < 2 + M; ++i) {
			for (int j = 0; j < 2 + M; ++j) {
				for (int k = 0; k <= goal; ++k) {
					diss[start+i][start + j] = min(diss[start + i][start + j], diss[start + i][k] + diss[k][start + j]);
				}
			}
		}
			vector<int>perms(M + 1);
		iota(perms.begin(), perms.end(), 1);
		int ans = 1e9;
		do {
			long long int dis = 0;
			int nowid = 0;
			int next = 0;
			while (perms[next] != 1) {
				dis += K*diss[start + nowid][start + perms[next]];
				dis -= cs[perms[next] - 2];
				nowid = perms[next];
				next++;
			}
			dis += K*diss[start + nowid][start + perms[next]];
			ans = min(ans, dis);
		} while (next_permutation(perms.begin(), perms.end()));
		cout << ans << endl;
	}
	
	return 0;
}

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