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.