#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,K; vector> E[202020]; int vis[201010]; int NV[201010]; int singlea; map sing,s2,p,p2; map,int> doub,d2; ll ret=0; int dfs(int cur,int pre) { NV[cur]=1; FORR(e,E[cur]) if(e.first!=pre && vis[e.first]==0) NV[cur]+=dfs(e.first,cur); return NV[cur]; } int dfs2(int cur,int pre,int TNV) { int tot=1; int ok=1; FORR(e,E[cur]) if(e.first!=pre && vis[e.first]==0) { int c = dfs2(e.first,cur,TNV); if(c!=-1) return c; tot += NV[e.first]; if(NV[e.first]*2>TNV) ok=0; } if((TNV-tot)*2>TNV) ok=0; if(ok) return cur; return -1; } void dfs3(int cur,int pre,int c1,int c2) { if(c2==-1) { //cout<>N>>K; FOR(i,N-1) { cin>>x>>y>>r; E[x-1].push_back({y-1,r}); E[y-1].push_back({x-1,r}); } split(0,0); cout<