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.