Tree coloring - MarisaOJ: Marisa Online Judge

Tree coloring

Time limit: 1000 ms
Memory limit: 256 MB
Given a tree of $n$ vertices, each vertex is initially white. Determine the maximum number of vertices that can be colored black, subject to the constraint that no two adjacent vertices can be black. ### Input - The first line contains an integer $n$. - The next $n - 1$ lines, each line contains 2 integers $u, v$, there is an edge between $u$ and $v$. ### Output - Print the maximum number of vertices can be colored black. ### Constraints - $1 \le n \le 10^5$. - $1 \le u, v \le n$. ### Example Input: ``` 5 1 2 2 3 1 4 4 5 ``` Output: ``` 3 ```