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

22199번 - Cat in a tree 서브태스크다국어

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

문제

A cat lives in a tree that has N nodes. She will demarcate her territory by “marking” some of the tree nodes. Marked nodes may not be closer to each other than distance D. Find the maximum number of nodes that the cat can mark.

입력

First line has two integers, N and D. The 0’th node is the root node of the tree. Then follows N − 1 lines, the i-th of which contain a single integer xi with 0 ≤ xi < i (starting with i = 1). This means that node xi is connected to node i.

출력

Output should contain one integer: the maximum number of nodes that can be marked.

제한

We always have 1 ≤ N, D ≤ 2 · 105. For subcases, the inputs have these further restrictions.

서브태스크

번호배점제한
111

N ≤ 18

240

N ≤ 1 500

349

No further restrictions.

예제 입력 1

4 3
0
0
1

예제 출력 1

2

예제 입력 2

3 1000
0
0

예제 출력 2

1

힌트

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2017 D번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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