Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;

int id[20],dist[20],cnt[20];
double dp[1<<15][15];
pair<int,int> prev[1<<15][15];

int W[1<<15];


int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++){
			cin >> id[i] >> dist[i] >> cnt[i];
		}
		for(int i = 0 ; i < (1<<15) ; i++)
			for(int j = 0 ; j < 15 ; j++)
				dp[i][j] = 1e12;
		for(int i = 0 ; i < n ; i++)
			dp[0][i] = 0;
		for(int i = 0 ; i < (1<<n) ; i++){
			int aaa = 0;
			for(int j = 0 ; j < n ; j++)
				if(i>>j&1) aaa += cnt[j];
			W[i] = aaa;
		}
		for(int i = 0 ; i < (1<<n) ; i++){
			for(int j = 0 ; j < n ; j++){
				for(int k = 0 ; k < n ; k++){
					double cost = abs(dist[j]-dist[k]) / ( 2000.0 / (70+20*W[i]) )+dp[i][j];
					if( dp[i|(1<<k)][k] > cost + 1e-9 ){
						prev[i|(1<<k)][k] = make_pair(i,j);
						dp[i|(1<<k)][k] = cost;
					}
				}
		
			}
		}
		double minCost = 1e12;
		for(int i = 0 ; i < n ; i++){
			minCost = min( dp[(1<<n)-1][i] , minCost) ;
		}
		for(int i = 0 ; i < n ; i++){
			if( fabs(minCost - dp[(1<<n)-1][i]) < 1e-9){
				int bit = (1<<n)-1;
				int k = i;
				vector<int> idd;
				while(bit){
					idd.push_back(k);
					pair<int,int> tmp = prev[bit][k];
					bit = tmp.first;
					k = tmp.second;
				}
				reverse(idd.begin(),idd.end());
				for(int j = 0 ; j < n ; j++)
					cout << id[idd[j]] << (char)(j==n-1?10:32);
			}
		}
	}	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:49: error: reference to 'prev' is ambiguous
   37 |                                                 prev[i|(1<<k)][k] = make_pair(i,j);
      |                                                 ^~~~
In file included from /usr/include/c++/14/string:47,
                 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_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:15: note:                 'std::pair<int, int> prev [32768][15]'
   10 | pair<int,int> prev[1<<15][15];
      |               ^~~~
a.cc:55:61: error: reference to 'prev' is ambiguous
   55 |                                         pair<int,int> tmp = prev[bit][k];
      |                                                             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:10:15: note:                 'std::pair<int, int> prev [32768][15]'
   10 | pair<int,int> prev[1<<15][15];
      |               ^~~~
a.cc:59:33: error: 'reverse' was not declared in this scope
   59 |                                 reverse(idd.begin(),idd.end());
      |                                 ^~~~~~~