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.