問題一覧 > 通常問題

No.2072 Anatomy

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 130
作問者 : chineristAC / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 8530 / 自分の提出
問題文最終更新日: 2022-09-16 18:47:26
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 360 (順位表) の他の問題:

Problem Statement

There is a simple connected undirected graph with $N$ vertices and $M$ edges. The edges are numbered from $1$ to $M$, and edge number $i\ (1\le i \le M)$ connects vertices $u_i,\ v_i$.

chinerist performed the following operation repeatedly until the graph had no edges left.

Operation
  • For each connected component of the graph, if the connected component has edges, delete the edge with the smallest edge number in it.

Find how many times chinerist performed the operation (even if multiple edges are deleted during an operation, it counts as $1$ operation).

Input

$N$ $M$
$u_1$ $v_1$
$u_2$ $v_2$
$\vdots$
$u_M$ $v_M$
  • $2 \leq N \leq 2 \times 10^5$
  • $N-1 \leq M \leq \min(\frac{N(N-1)}{2},\ 2\times 10^5)$
  • $1 \leq u_i < v_i \leq N$
  • The input consists of integers.
  • The given graph is a simple connected undirected graph.

Output

Output the answer.

Print a newline at the end.

Sample

Sample 1
Input
4 3
2 3
1 2
3 4
Output
2

In the first operation (number $1$), the edge between vertices $2,\ 3$ is deleted, and the graph splits into a connected component consisting of vertices $1,\ 2$ and a connected component consisting of vertices $3,\ 4$.

In operation number $2$, the only $1$ edge in each connected component is deleted, and all edges have now been deleted.

Sample 2
Input
12 20
6 8
1 5
3 5
2 9
2 11
11 12
5 9
7 12
4 11
5 8
7 10
7 11
1 7
7 8
7 9
4 10
6 12
8 11
2 3
1 12
Output
15

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。