#include<iostream> #include<algorithm> #include<cstdlib> using namespace std; const int limit = 999999; int min_ = limit, book[101], n, e[101][101]; void dfs(int cur, int dis){ int j; if (dis > min_) return; if (cur == n) { if (dis < min_) min_ = dis; return; } for (j = 1; j <= n; j++) { if (e[cur][j] != limit && book[j] == 0) { book[j] = 1; dfs(j, dis + e[cur][j]); book[j] = 0; } } return;
}
|