#Lutece2604. 图像分割
图像分割
Migrated from Lutece 2604 图像分割
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
给出一个 个点, 条边的连通无向图,你需要给每个点染上两种颜色中的一种,不能不染。
若编号为 的点被染成 色,你可以获得价值 的分数,若被染上 色则获得 的分数。
对于编号为 的边,若它的两个端点颜色不同,则你会被扣除价值 的分数。
求你能获得的最大的最终分数。
Input
第一行两个数,分别为点数 和边数 。
接下来一行 个数,第 个数为 。
再接下来一行 个数,第 个数为 。
接下来 行,每行三个数 ,表示边的两个端点 和这条边对应的价值 。
Output
输出一个数表示答案。
Samples
7 11
705698 598721 559214 654137 511975 508730 844971
683515 920366 670141 740061 640839 896312 616508
1 2 60
1 3 65
1 6 69
1 5 17
1 4 34
2 6 78
3 4 52
3 5 19
4 7 44
4 6 9
6 7 33
5418066
Constraints
, ,。 保证不出现重边和自环。
Resources
2021 UESTC ICPC Training for Graph