#abc229f. F - Make Bipartite
F - Make Bipartite
Score : points
问题描述
给定一个包含 个顶点的无向图。
这些顶点依次称为 Vertex 、Vertex 、、Vertex 。
对于每个 ,图中存在一条权重为 的无向边,连接 Vertex 和 Vertex 。
另外,对于每个 ,图中还存在一条权重为 的无向边,连接 Vertex 和 Vertex 。(这里,Vertex 实际上表示 Vertex 。)
除了上述这 条边以外,图中没有其他边。
现在让我们从这个图中删除一些边,使得图变为二分图。
需要删除的边的最小总权重是多少?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is an undirected graph with vertices.
The vertices are called Vertex , Vertex , , Vertex .
For each , the graph has an undirected edge with a weight of connecting Vertex and Vertex .
Additionally, for each , the graph has an undirected edge with a weight of connecting Vertex and Vertex . (Here, Vertex stands for Vertex .)
The graph has no edge other than these edges above.
Let us delete some of the edges from this graph so that the graph will be bipartite.
What is the minimum total weight of the edges that have to be deleted?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5
31 4 159 2 65
5 5 5 5 10
Sample Output 1
16
Deleting the edge connecting Vertices (weight: ), the edge connecting Vertices (weight: ), and the edge connecting Vertices (weight: ) makes the graph bipartite.
Sample Input 2
4
100 100 100 1000000000
1 2 3 4
Sample Output 2
10
update @ 2024/3/10 10:01:45