QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22309. 携帯電話ネットワーク

Statistics

Farmer John は交流を促すため全ての牛に携帯電話を与えます。通信のため $N$ 牧草地($1 \le N \le 10,000$、番号 $1,\ldots,N$)に基地局が必要です。

隣接する組はちょうど $N-1$。任意の $A$、$B$($1 \le A \le N; 1 \le B \le N; A \ne B$)には、$A$ から始まり $B$ で終わる隣接牧草地列があります。基地局は牧草地にのみ置け、その地と全ての隣接地をカバーします。

全牧草地に通信を提供する最小基地局数を求めてください。

入力

標準入力から読みます。

  • 1行目:整数 $N$。
  • $2,\ldots,N$ 行目:空白区切りの整数 $A$、$B$、隣接する組です。

出力

標準出力に書きます。

  • 1行目:最小基地局数を表す整数。

入出力例

入力 1

5
1 3
5 2
4 3
3 5

出力 1

2

注記

5地あり、1と3、5と2、4と3、3と5が隣接します。図は次のよう(または類似の形)です:

               4  2
               |  |
            1--3--5

2と3、または3と5に基地局を置けます。

問題作成:Jeffrey Wang、2007

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.