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

19463번 - Jumping on a Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB579822.857%

문제

You are given a tree on $n$ vertices. Suppose we are at the vertex $v$. In one step we can go from $v$ to any other vertex $u$ such that there are exactly $d$ edges on the shortest path between $v$ and $u$. A vertex $u$ is reachable from $v$ if we can get to $u$ from $v$ using zero or more steps.

Naturally, all vertices can be divided into reachability classes. A reachability class is a set of vertices $C$ such that any vertex in $C$ is reachable from any other vertex in $C,ドル but no vertex which is not in $C$ is reachable from any vertex in $C$. How many reachability classes are there in the given tree?

입력

The first line contains two space-separated integers $n$ and $d$ (1ドル \leq n \leq 10^6,ドル 0ドル \leq d \leq n$).

Next $n - 1$ lines describe edges of the tree. Each line contains two space-separated integers --- indices of vertices connected by the corresponding edge. Indices are 1-based.

출력

Print one integer --- the number of reachability classes.

제한

예제 입력 1

4 2
1 2
2 3
3 4

예제 출력 1

2

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2016 > Day 3: Moscow IPT Contest J번

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

출처

대학교 대회

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

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