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

19420번 - Tree Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB4110516.129%

문제

Consider the following game about coloring edges in a tree.

You are given a tree. Initially, the color of all edges is white. Let a valid path be a simple path such that all its edges are white, and the two endpoints are leaves in the tree. On each step of this game, you can choose a valid path and paint all its edges black. You cannot stop your game until you cannot find any valid path.

The purpose of this game is to use the minimum number of steps to complete the game. Please find the minimum number of steps for the given tree.

입력

The first line of input contains one integer $N$ indicating the number of nodes in the given tree.

Each of the following $N-1$ lines contains two integers $x$ and $y$ indicating that $x$-th node and $y$-th node are connected by an edge in the given tree. Nodes are numbered from 1ドル$ to $N$.

출력

Output one integer: the minimum number of steps required to complete the game on the given tree.

제한

  • 2ドル \le N \le 10^5$
  • 1ドル \le x, y \le N$
  • The given graph is a tree.

예제 입력 1

7
1 2
1 3
2 4
2 5
3 6
3 7

예제 출력 1

1

예제 입력 2

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

예제 출력 2

3

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 7: National Taiwan U Contest I번

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

출처

대학교 대회

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

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