AT_abc461_g.Graph Problem 2026
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a simple undirected graph with N vertices and M edges.
The vertices are numbered 1 through N and the edges are numbered 1 through M; edge i connects vertices ui and vi.
Assign a non-negative integer weight Wj not greater than 2026 to each vertex j so that the following condition is satisfied:
- Wui+Wvi≤2026 for each edge i.
Find the maximum possible value of the sum of all vertex weights (that is, ∑j=1NWj).
给定一个包含 N 个顶点和 M 条边的简单无向图。
顶点编号为 1 到 N,边编号为 1 到 M;第 i 条边连接顶点 ui 和 vi。
对每个顶点 j 分配一个非负整数权重 Wj,且满足 Wj≤2026,使得以下条件成立:
- 对每条边 i,均有 Wui+Wvi≤2026。
求所有顶点权重之和(即 ∑j=1NWj)的最大可能值。
输入格式
The input is given from Standard Input in the following format:
N M
u1 v1
u2 v2
⋮
uM vM
输入从标准输入中按以下格式给出:
N M
u1 v1
u2 v2
⋮
uM vM
输出格式
Output the answer on a single line.
在单行中输出答案。
输入输出样例
输入#1
3 2 1 2 2 3
输出#1
4052
输入#2
4 6 1 2 2 3 1 4 2 4 1 3 3 4
输出#2
4052
输入#3
2 1 1 2
输出#3
2026
说明/提示
Sample 1 Explanation:
By assigning weights 2026,0,2026 to vertices 1,2,3, respectively, the sum of all vertex weights becomes 4052, and it is impossible to make it larger, so the answer is 4052.
Constraints
- 1≤N≤5×104
- 0≤M≤5×104
- 1≤ui<vi≤N
- (u1,v1),(u2,v2),…,(uM,vM) are pairwise distinct.
- All input values are integers.
样例 1 解释:
将顶点 1,2,3 的权重分别设为 2026,0,2026,则所有顶点权重之和为 4052,且无法使该和更大,因此答案为 4052。
限制条件
- 1≤N≤5×104
- 0≤M≤5×104
- 1≤ui<vi≤N
- (u1,v1),(u2,v2),…,(uM,vM) 两两互不相同。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?