#include<bits/stdc++.h>
using namespace std;
int n;int mp[20][20];
bool vis[20];
using ll=long long;
ll ans=1e9+5;
void dfs(int x,ll ann){//x是到了哪座岛出发,ann是花费
if(x==n){
for(int i=1;i<n;i++){
if(!vis[i])return;
}
ans=min(ans,ann);
return;
}
if(ann>ans){
return;
}
for(int j=1;j<=n;j++){
if(x==j) continue;
if(vis[j]) continue;
vis[j]=true;
dfs(j,ann+mp[x][j]);
vis[j]=false;
}
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>mp[i][j];
}
}
vis[1]=true;
dfs(1,0);
cout<<ans<<endl;
return 0;
}
0 回复
0 转发
1 喜欢
13 阅读



