SP28465 TAP2016K - Koalas
题目描述
经过一个晚上的桉树叶进食技巧训练,Mabel Eucaliptos 准备去挑战她的死对头 Pacífica,决战即将决定谁才是真正的考拉女王。
### 输入格式
输入中包含多组测试数据。对于每组测试数据,第一行有三个整数 $N$、$M$ 和 $P$,分别代表森林中的树的数量、Mabel 的起始位置和 Pacífica 的起始位置($2 \leq N \leq 10^5$ 且 $1 \leq M, P \leq N$,且 $M \neq P$)。第二行给出 $N$ 个整数 $C_1, C_2, \ldots, C_N$,每个整数 $C_i$ 代表第 $i$ 棵树上的叶子数量($1 \leq C_i \leq 100$,其中 $i = 1, 2, \ldots, N$)。接下来的 $N-1$ 行中每行有两个整数 $U$ 和 $V$,表示树 $U$ 和树 $V$ 之间有一根绳索连接($1 \leq U, V \leq N$ 且 $U \neq V$)。
### 输出格式
针对每组测试数据,输出一行,表示在 Mabel 和 Pacífica 都采取最佳策略的情况下,Mabel 吃掉的叶子数量与 Pacífica 吃掉的叶子数量的差值。
**本翻译由 AI 自动生成**
输入格式
There are multiple test cases in the input file. For each test case, the first line contains three integer numbers **N**, **M** y **P**, representing the number of trees in the forest, the tree where Mabel starts, and the tree where Peaceful starts, respectively (**2 ****10 $ ^{5} $** and **1** ****M, P** ****N** with **M ≠ P**). The second line contains **N** integer numbers **C $ _{1} $ , C $ _{2} $ , ..., C $ _{N} $** , representing **C $ _{i} $** the number of leaves contained in the **i**-th tree (**1** ****C $ _{i} $** ****100** for **i = 1, 2, ..., N**). Each of the following **N-1** lines contains two integer numbers **U** and **V**, representing that there is a rope connecting trees number **U** and **V** (**1** ****U, V** ****N** with **U ≠ V**).****************
输出格式
For each test case, output a single line containing an integer number, representing the difference between the number of leaves eaten by Mabel and the number of leaves eaten by Peaceful if both of them play optimally.