Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)
D
Hamiltonian Spanning Tree
Codeforces
2200
原题
← CE →
翻译中…

A group of $*n*$ cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are image roads in total. It takes exactly $*y*$ seconds to traverse any single road.

翻译中…

A spanning tree is a set of roads containing exactly $*n* - 1$ roads such that it's possible to travel between any two cities using only these roads.

翻译中…

Some spanning tree of the initial network was chosen. For every road in this tree the time one needs to traverse this road was changed from $*y*$ to $*x*$ seconds. Note that it's not guaranteed that $*x*$ is smaller than $*y*$.

翻译中…

You would like to travel through all the cities using the shortest path possible. Given $*n*$, $*x*$, $*y*$ and a description of the spanning tree that was chosen, find the cost of the shortest path that starts in any city, ends in any city and visits all cities exactly once.

翻译中…

Input

翻译中…

The first line of the input contains three integers $*n*$, $*x*$ and $*y*$ ($2 ≤ *n* ≤ 200 000, 1 ≤ *x*, *y* ≤ 10^{9}$).

翻译中…

Each of the next $*n* - 1$ lines contains a description of a road in the spanning tree. The $*i*$-th of these lines contains two integers $*u*_{*i*}$ and $*v*_{*i*}$ ($1 ≤ *u*_{*i*}, *v*_{*i*} ≤ *n*$) — indices of the cities connected by the $*i*$-th road. It is guaranteed that these roads form a spanning tree.

翻译中…

Output

翻译中…

Print a single integer — the minimum number of seconds one needs to spend in order to visit all the cities exactly once.

翻译中…

Note

翻译中…

In the first sample, roads of the spanning tree have cost $2$, while other roads have cost $3$. One example of an optimal path is image.

翻译中…

In the second sample, we have the same spanning tree, but roads in the spanning tree cost 3, while other roads cost 2. One example of an optimal path is image.

翻译中…

样例

Input #1
5 2 3
1 2
1 3
3 4
5 3
Output #1
9
InputCopy OutputCopy
Input #2
5 3 2
1 2
1 3
3 4
5 3
Output #2
8
InputCopy OutputCopy
题目信息
题号
618D
时间限制
2 s
内存限制
256 MB
标签
DFS 及类似
动态规划
图匹配
贪心
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。