QOJ.ac

QOJ

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

#22499. התעמלות הפרות

Statistics

Farmer John מתמיד בשמירת כושר הפרות בתרגול בדרכי המרעה. קודקודים וקשתות דו כיווניות נותנים בדיוק מסלול פשוט אחד לכל זוג, בדומה לעץ. כל הקשתות המפותלות שוות אורך באופן מפתיע.

פרות פיקחות קוראות למרחק הגדול ביותר בין שני קודקודים בקבוצה אורך המסלול. אם גדול מדי, מסרבות לכל תרגול.

מיפה $V$ קודקודים ($2 \le V \le 100,000$), מספרים $1..V$. חסימת דרך בין שניים יוצרת יותר קבוצות ומקטינה את שני האורכים.

מעץ מחובר לחלוטין, $S$ חסימות ($1 \le S \le V-1$) יוצרות $S+1$ קבוצות. בחרו למזער את האורך הגדול ביותר בכל הקבוצות.

כל $V-1$ הקשתות מחברות $A_{i}$ ($1 \le A_{i} \le V$), $B_{i}$ ($1 \le B_{i} \le V; A_{i} \ne B_{i}$).

דוגמה קווית של 7 קודקודים:

                   1---2---3---4---5---6---7

שתי חסימות אפשריות: 1---2 | 3---4 | 5---6---7

האורך הגדול $2$ הוא התשובה, אי אפשר יותר טוב.

מגבלת זמן: 2 שניות

מגבלת זיכרון: 32 MB

קלט

  • שורה 1: שני שלמים $V$, $S$ ברווח.
  • שורות $2..V$: שני שלמים $A_{i}$, $B_{i}$ ברווח.

פלט

  • שורה 1: שלם, האורך המרבי המיטבי עם $S$ חסימות.

דוגמאות

קלט 1

7 2
6 7
3 4
6 5
1 2
3 2
4 5

פלט 1

2

מחבר הבעיה: Michael Cohen, 2010

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.