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

7729번 - Tree Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 64 MB9510811.940%

문제

MaĹĽko and Kubko, both wery enjoyed playing games, have discovered new type of game: tree game. In this game first player chooses vertex of a tree. Then players (beginning with second player) alternately choose neighboor of last choosed vertex which was not choosed before, until one player can’t make a move. This player is then determined as a looser and the other one is the winner. MaĹĽko is beginning the game but unforutnatelly Kubko is very experienced player and he will never make a mistake. Therefore MaĹĽko has asked you for help.

Our tree has N vertices conventionally numbered 1..N and exactly N − 1 edges connecting them. Write a program, which determines all vertieces in which MaĹĽko can begin the game and will win altrough Kubko will be playing perfectly.

입력

On the first line, there is one single number N, (1 ≤ N ≤ 2 000 000), which is equal to the number of nodes in the tree. N − 1 lines follows, on the i-th line is a single integer ai, which means there is edge in the tree connecting (i + 1)-th vertex with vertex ai. (Moreover you can suppose ai ≤ i).

출력

Output consists of several lines, on each one there is single number of node, where MaĹĽko can begin the game and can win, regardless how is Kubko playing. Numbers on the ouput are sorted in ascending order.

제한

예제 입력 1

3
1
1

예제 출력 1

2
3

예제 입력 2

6
1
1
1
4
5

예제 출력 2

2
3
4
6

힌트

출처

Camp > Czech, Polish and Slovak Preparation Camp > CPSPC 2010 4-3번

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

출처

대학교 대회

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

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