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

15584번 - Cow at Large (Platinum) 다국어

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

문제

Cornered at last, Bessie has gone to ground in a remote farm. The farm consists of $N$ barns (2ドル \leq N \leq 7 \cdot 10^4$) and $N-1$ bidirectional tunnels between barns, so that there is a unique path between every pair of barns. Every barn which has only one tunnel is an exit. When morning comes, Bessie will surface at some barn and attempt to reach an exit.

But the moment Bessie surfaces at some barn, the law will be able to pinpoint her location. Some farmers will then start at various exit barns, and attempt to catch Bessie. The farmers move at the same speed as Bessie (so in each time step, each farmer can move from one barn to an adjacent barn). The farmers know where Bessie is at all times, and Bessie knows where the farmers are at all times. The farmers catch Bessie if at any instant a farmer is in the same barn as Bessie, or crossing the same tunnel as Bessie. Conversely, Bessie escapes if she reaches an exit barn strictly before any farmers catch her.

Bessie is unsure at which barn she should surface. For each of the $N$ barns, help Bessie determine the minimum number of farmers who would be needed to catch Bessie if she surfaced there, assuming that the farmers distribute themselves optimally among the exit barns.

입력

The first line of the input contains $N$. Each of the following $N-1$ lines specify two integers, each in the range 1ドル \ldots N,ドル describing a tunnel between two barns.

출력

Please output $N$ lines, where the $i$th line of output tells the minimum number of farmers necessary to catch Bessie if she surfaced at the $i$th barn.

제한

예제 입력 1

7
1 2
1 3
3 4
3 5
4 6
5 7

예제 출력 1

3
1
3
3
3
1
1

힌트

출처

Olympiad > USA Computing Olympiad > 2017-2018 Season > USACO 2018 January Contest > Platinum 2번

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

출처

대학교 대회

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

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