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.