AT_abc461_g.Graph Problem 2026

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a simple undirected graph with NN vertices and MM edges.
The vertices are numbered 11 through NN and the edges are numbered 11 through MM; edge ii connects vertices uiu_i and viv_i.
Assign a non-negative integer weight WjW_j not greater than 20262026 to each vertex jj so that the following condition is satisfied:

  • Wui+Wvi≤2026W_{u_i}+W_{v_i} \leq 2026 for each edge ii.

Find the maximum possible value of the sum of all vertex weights (that is, ∑j=1NWj\sum_{j=1}^{N}{W_j}).

给定一个包含 NN 个顶点和 MM 条边的简单无向图。
顶点编号为 11 到 NN,边编号为 11 到 MM;第 ii 条边连接顶点 uiu_i 和 viv_i。
对每个顶点 jj 分配一个非负整数权重 WjW_j,且满足 Wj≤2026W_j \leq 2026,使得以下条件成立:

  • 对每条边 ii,均有 Wui+Wvi≤2026W_{u_i}+W_{v_i} \leq 2026。

求所有顶点权重之和(即 ∑j=1NWj\sum_{j=1}^{N}{W_j})的最大可能值。

输入格式

The input is given from Standard Input in the following format:

NN MM
u1u_1 v1v_1
u2u_2 v2v_2
⋮\vdots
uMu_M vMv_M

输入从标准输入中按以下格式给出:

NN MM
u1u_1 v1v_1
u2u_2 v2v_2
⋮\vdots
uMu_M vMv_M

输出格式

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,20262026, 0, 2026 to vertices 1,2,31, 2, 3, respectively, the sum of all vertex weights becomes 40524052, and it is impossible to make it larger, so the answer is 40524052.

Constraints

  • 1≤N≤5×1041 \leq N \leq 5 \times 10^4
  • 0≤M≤5×1040 \leq M \leq 5 \times 10^4
  • 1≤ui<vi≤N1 \leq u_i \lt v_i \leq N
  • (u1,v1),(u2,v2),…,(uM,vM)(u_1,v_1),(u_2,v_2),\dots,(u_M,v_M) are pairwise distinct.
  • All input values are integers.

样例 1 解释:
将顶点 1,2,31, 2, 3 的权重分别设为 2026,0,20262026, 0, 2026,则所有顶点权重之和为 40524052,且无法使该和更大,因此答案为 40524052。

限制条件

  • 1≤N≤5×1041 \leq N \leq 5 \times 10^4
  • 0≤M≤5×1040 \leq M \leq 5 \times 10^4
  • 1≤ui<vi≤N1 \leq u_i \lt v_i \leq N
  • (u1,v1),(u2,v2),…,(uM,vM)(u_1,v_1),(u_2,v_2),\dots,(u_M,v_M) 两两互不相同。
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页