#include #include #include #include #define VERY_LARGE 1000000000 void genrand ( int *x, int *y, int **d, int n ) { int i, j, t; for (i=0; i=0; --i) { for (j=0; j<=i; ++j) { if (x[j] > x[j+1]) { t = x[j]; x[j] = x[j+1]; x[j+1] = t; } } } /**** For reproducing the sample **** x[0] = 21; x[1] = 36; x[2] = 59; x[3] = 87; x[4] = 193; x[5] = 286; x[6] = 561; x[7] = 737; x[8] = 821; x[9] = 856; x[10] = 958; x[11] = 962; y[0] = 993; y[1] = 490; y[2] = 101; y[3] = 740; y[4] = 997; y[5] = 19; y[6] = 131; y[7] = 100; y[8] = 614; y[9] = 246; y[10] = 136; y[11] = 967; ****/ for (i=0; i=nearesti+1; --i) p[i+1] = p[i]; p[nearesti+1] = nearestj; ++k; visited[nearestj] = 1; } for (i=0; i>1][j] + d[j][t]; if (thiscost < best[i][t]) { best[i][t] = thiscost; last[i][t] = j; } } } } } bestcost = VERY_LARGE; for (t=1; t=1; --i) { j = last[u][j]; p[i] = j; u ^= (1 << (j-1)); } p[0] = 0; for (i=0; i