当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5438:Ponds

题目描述
Betty owns a lot of ponds, some of them are connected with other ponds by pipes, and there will not be more than one pipe between two ponds. Each pond has a value $v$.

Now Betty wants to remove some ponds because she does not have enough money. But each time when she removes a pond, she can only remove the ponds which are connected with less than two ponds, or the pond will explode.

Note that Betty should keep removing ponds until no more ponds can be removed. After that, please help her calculate the sum of the value for each connected component consisting of a odd number of ponds
输入解释
The first line of input will contain a number $T (1 \leq T \leq 30)$ which is the number of test cases.

For each test case, the first line contains two number separated by a blank. One is the number $p (1 \leq p \leq 10^4)$ which represents the number of ponds she owns, and the other is the number $m (1 \leq m \leq 10^5)$ which represents the number of pipes.

The next line contains $p$ numbers $v_1, . . . , v_p$, where $v_i (1 \leq v_i \leq 10^8)$ indicating the value of pond $i$.

Each of the last $m$ lines contain two numbers $a$ and $b$, which indicates that pond $a$ and pond $b$ are connected by a pipe.
输出解释
For each test case, output the sum of the value of all connected components consisting of odd number of ponds after removing all the ponds connected with less than two pipes.
输入样例
1
7 7
1 2 3 4 5 6 7
1 4
1 5
4 5
2 3
2 6
3 6
2 7
输出样例
21
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5438

最后修改于 2020-10-25T23:22:40+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1500/1000MS(Java/Others) 131072/131072K(Java/Others)