아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Even Forest

시간 제한3초메모리 제한512 MB

요약
트리에서 간선을 최소한으로 제거해 남은 각 성분에서 두 리프 사이의 홀수 길이 경로가 없도록 만든다.
난이도

보통10점 중 7점

유형
트리, DFS, 그리디, 동적 계획법
정답자
아직 제출이 없습니다

문제

An undirected tree is called even if there is no simple path of odd length connecting two of its leaves. In particular, a tree with just one vertex is considered even.

You are given an undirected tree GG with vertices numbered from 11 to nn. A graph obtained by removing some (possibly none) of the edges of GG is called a forest: it consists of one or more disjoint trees. Determine the minimum possible number kk such that we can remove kk edges of GG in such a way that the resulting forest consists only of even trees.

입력

The first line contains one integer nn (1≤n≤1061 \le n \le 10^6).

Each of the next n−1n - 1 lines contains two integers u_iu\_i and v_iv\_i (1≤u_i,v_i≤n1 \le u\_i, v\_i \le n) denoting an edge connecting vertex u_iu\_i and vertex v_iv\_i.

The graph is guaranteed to be a tree.

출력

Output the minimum number of edges kk such that we can remove kk edges of GG in such a way that each tree in the resulting forest is even.

예제2

  1. 예제 1

    입력
    4
    1 2
    2 3
    3 4
    
    예상 출력
    1
    
  2. 예제 2

    입력
    4
    1 2
    1 3
    1 4
    
    예상 출력
    0