QOJ.ac

QOJ

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

#22309. Sieć telefonii komórkowej

Statistics

Farmer John daje każdej krowie telefon, aby zachęcić do kontaktów. Potrzebuje nadajników na $N$ pastwiskach ($1 \le N \le 10,000$), o numerach $1,\ldots,N$, by mogły rozmawiać.

Dokładnie $N-1$ par sąsiaduje; dla dowolnych $A$, $B$ ($1 \le A \le N; 1 \le B \le N; A \ne B$) ciąg sąsiednich pastwisk zaczyna się w $A$ i kończy w $B$. Nadajniki tylko na pastwiskach, każdy obejmuje własne i wszystkie sąsiednie.

Znajdź minimum nadajników obejmujących każde pastwisko.

Wejście

Czytaj ze standardowego wejścia.

  • Wiersz 1: liczba całkowita $N$.
  • Wiersze $2,\ldots,N$: sąsiednia para, całkowite $A$, $B$ oddzielone spacją.

Wyjście

Pisz na standardowe wyjście.

  • Wiersz 1: liczba całkowita, minimum nadajników.

Przykład

Wejście 1

5
1 3
5 2
4 3
3 5

Wyjście 1

2

Uwagi

5 pastwisk: sąsiadują 1 i 3, 5 i 2, 4 i 3, 3 i 5. Geometrycznie wygląda to tak (lub podobnie):

               4  2
               |  |
            1--3--5

Nadajniki mogą być na 2 i 3 lub na 3 i 5.

Autor zadania: 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.