Logo
(追記) (追記ここまで)

21141번 - Kth Subtree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB262914624.211%

문제

You are given an unrooted labeled tree. A subtree is a connected subgraph of this tree. The size of a subtree is the number of nodes in the subtree. Two subtrees are different if there is at least one node which is in one but not the other. The largest subtree is the original tree itself.

Compute the size of the $K$th smallest non-empty subtree.

입력

The first line of input contains two integers $n$ (1ドル \le n \le 5,000$) and $K$ (1ドル \le K \le 10^{18}$), where $n$ is the number of nodes in the tree, and you’re looking for the size of the $K$th smallest subtree. The nodes are numbered 1ドル$ through $n$.

Each of the next $n - 1$ lines contains a pair of integers $u$ and $v$ (1ドル \le u, v \le n,ドル $u \ne v$), which represents an undirected edge between nodes $u$ and $v$. All edges are distinct. It is guaranteed that the edges form a single tree.

출력

Output a single integer, which is the number of nodes in the $K$th smallest non-empty subtree of the input tree. If there are fewer than $K$ non-empty subtrees of the given tree, output $-1$.

제한

예제 입력 1

2 1
1 2

예제 출력 1

1

예제 입력 2

2 3
1 2

예제 출력 2

2

예제 입력 3

5 10
1 2
2 3
3 4
4 5

예제 출력 3

3

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2020 Southeast USA Regional Programming Contest H번

ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 1 L번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2020 Mid-Atlantic USA Regional Contest K번

ICPC > Regionals > North America > South Central USA Regional > 2020 South Central USA Regional Contest H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /