QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#9696. 分析

Estadísticas

给定一棵包含 $n$ 个顶点的无向树,Little Q 想要删除所有的树边。初始时,他选择一个起始顶点。在每次操作中,他可以执行以下三种动作之一:

  1. 选择一条相邻的未删除边,经过它,并删除该边。
  2. 支付 $A$ 的代价来恢复一条已删除的边。
  3. 支付 $B$ 的代价传送至任意顶点。

求删除所有树边所需的最小总代价。

输入格式

第一行包含三个正整数:$n, A, B$ ($1 \le n \le 5 \cdot 10^5$; $1 \le A, B \le 10^9$)。 接下来的 $n-1$ 行,每行包含两个整数 $u$ 和 $v$,表示连接两个顶点的一条边 ($1 \le u, v \le n$)。

输出格式

输出一个整数:删除所有树边所需的最小总代价。

样例

样例输入 1

5 100 1000
1 2
2 3
3 4
4 5

样例输出 1

0

样例输入 2

5 100 200
1 2
1 3
2 4
2 5

样例输出 2

100

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.