最近点对这题有谁可以给我看一下吗?谢谢啦!这是我的代码,求调:
#include<bits/stdc++.h>
using namespace std;
int n,u,v,w,minn=1e9,now,vis[1010];
struct node{
int where,qu;
};
vector<node> t[1010];
void dfs(int x){
int size=t[x].size();
for(int i=0;i<size;i++){
if(vis[t[x][i].where]!=1){
vis[t[x][i].where]=1;
now+=t[x][i].qu;
if(now<minn)
minn=now;
dfs(t[x][i].where);
now-=t[x][i].qu;
vis[t[x][i].where]=0;
}
}
return;
}
int main(){
cin>>n;
while(cin>>u>>v>>w){
node nod;
nod.where=v;
nod.qu=w;
t[u].push_back(nod);
nod.where=u;
t[v].push_back(nod);
}
for(int i=1;i<=n;i++){
memset(vis,0,sizeof(vis));
now=0;
dfs(i);
}
cout<<minn;
return 0;
}