#P2899. [USACO08JAN] Cell Phone Network G

    ID: 3730 远端评测题 1000ms 125MiB 尝试: 1 已通过: 1 显示难度普及+/提高− 上传者: 标签>2008USACO排序树形 DP拓扑排序

[USACO08JAN] Cell Phone Network G

Problem Description

Farmer John wants all his cows to use cell phones so that they can communicate. He needs to build several cell towers among NN pastures. A tower provides coverage to the pasture it is placed on and to any pasture adjacent to it. You are given N1N-1 adjacency pairs (A,B)(A, B) between pastures. What is the minimum number of towers required so that every pasture has coverage?

Input Format

Line 1: an integer NN.

Lines 2 through NN: each line contains two integers separated by a space, giving one adjacent pair of pastures AA and BB.

Output Format

A single integer, the minimum number of towers to install.

5
1 3
5 2
4 3
3 5

2

Hint

For all testdata, 1N1041 \leq N \leq 10^4, 1A,BN1 \leq A, B \leq N, ABA \neq B.

Translated by ChatGPT 5