Submitted 4 years 9 months 1 day ago
Thu Feb 13 19:15:19 CST 2020
Judger: ZJS
Dataset Version: v0
0 ms /
0 KB
Final
0
Problem: lss3.tour
Language: GNU C++ 11
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test0.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test1.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test2.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test3.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test4.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test5.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test6.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test7.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test8.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test9.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test10.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test11.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test12.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test13.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test14.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test15.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test16.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test17.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test18.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/small/test19.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test0.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test1.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test2.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test3.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test4.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test5.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test6.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test7.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test8.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test9.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test10.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test11.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test12.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test13.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test14.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test15.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test16.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test17.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test18.out (No such file or directory)
java.io.FileNotFoundException: /mnt/g/test/client/data/lss3_tour/big/test19.out (No such file or directory)
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
bool debug=true;
/* *************************************
* Written in New Computer *
* The following code belongs to *
* XiaoGeNintendo of HellHoleStudios *
*************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
os<<ptt.first<<","<<ptt.second;
return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
os<<"{";
for(int i=0;i<vt.size();i++){
os<<vt[i]<<" ";
}
os<<"}";
return os;
}
int n;
vector<pii> nei[100005];
ll dis[100005];
void dfs(int pos,int par,ll dist){
dis[pos]=dist;
for(pii x:nei[pos]){
if(x.first==par){
continue;
}
dfs(x.first,pos,dist+x.second);
}
}
void runDis(int s){
memset(dis,0,sizeof(dis));
dfs(s,-1,0);
}
int main(int argc,char* argv[]){
qi;
cin>>n;
ll ans=0;
for(int i=0;i<n-1;i++){
int a,b,c;
cin>>a>>b>>c;
a--;b--;
ans+=2ll*c;
nei[a].push_back(make_pair(b,c));
nei[b].push_back(make_pair(a,c));
}
runDis(0);
ll mx=0;
for(int i=0;i<n;i++){
if(dis[i]>dis[mx]){
mx=i;
}
}
runDis(mx);
mx=0;
for(int i=0;i<n;i++){
mx=max(mx,dis[i]);
}
cout<<ans-mx<<endl;
return 0;
}