Logo
(追記) (追記ここまで)

19010번 - Remove the Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB18121292.308%

문제

You are given an unweighted tree with $n$ vertices, numbered by integers from 1ドル$ to $n$. Let us define the remove operation as follows:

  1. choose an arbitrary path in the current graph (a path with only one vertex is valid),
  2. remove all vertices along this path, and all edges incident to them.

Calculate the minimum number of such operations to remove all edges. Note that it is allowed to leave some vertices not removed.

입력

The first line contains one integer $n$ (2ドル \le n \le 2 \cdot 10^5$), the number of vertices in the tree.

The $i$-th of the next $n - 1$ lines contains integers $a_i$ and $b_i$ (1ドル \le a_i, b_i \le n,ドル $a_i \ne b_i$), the numbers of vertices connected by edge $i$.

It is guaranteed that the given graph is a tree.

출력

Output one integer: the minimum number of remove operations.

제한

예제 입력 1

4
1 2
1 3
1 4

예제 출력 1

1

예제 입력 2

6
3 4
2 3
5 3
1 3
3 6

예제 출력 2

1

예제 입력 3

11
1 2
2 3
3 4
4 5
5 6
6 11
5 9
9 10
3 7
7 8

예제 출력 3

2

힌트

The third example corresponds to the following image:

출처

Camp > Petrozavodsk Programming Camp > Summer 2018 > Day 7: Izhevsk STU + Ufa SATU Contest B번

Contest > Open Cup > 2018/2019 Season > Stage 2: Grand Prix of Udmurtia B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /