Problem 2996 --Squrirrel

2996: Squrirrel

"
Time Limit $4$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Master magician `eom` is searching for his naughty squirrel. The squirrel hides at a node of a tree, while its owner `eom` has no idea which node it hides at. As a magician, `eom` can choose a node and release many magical creatures to search his squirrel in all directions at the speed of 1. Besides, he can choose a pair of adjacent nodes on the tree and reduce the distance between them to 0 before releasing magical creatures. Please help him to find the start node to release magical creatures, so that `eom` can find his squirrel in the shortest time even in the worst condition. Note that `eom` is full of wisdom, so that he can optimally make decision to reduce the distance after the start node is determined.
The first line contains a integer T(1≤T≤20)(1≤T≤20), indicating there are T test cases followed. 

For each test case, the first line contains one integers nn: the number of nodes of the tree(1≤n≤200,000)(1≤n≤200,000)

In the following n−1n−1 lines, each line has three integers uu,vv and ww, indicating there exists a line between node uu and vv, which length equals to ww(1≤u,v≤n,1≤w≤200)(1≤u,v≤n,1≤w≤200)

It is guaranteed that (1≤∑n≤2,000,000)(1≤∑n≤2,000,000)


(1≤T≤20)(1≤T≤20) 

(1≤n≤200,000)(1≤n≤200,000) 

(1≤u,v≤n,1≤w≤200)(1≤u,v≤n,1≤w≤200) 

(1≤∑n≤2000000)
Output two integers. The first one is the index of the start node you should choose and the second one is the least time required in the worst condition. If there are multiple possible ways to choose the start node to minimize the time, the index of start node chosen should be minimum. 
1

5

1 5 1
1 2 1
2 3 2
3 4 1
1 2

推荐代码 查看2996 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 2019 Multi-University Training Contest 3 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛