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

6782번 - Unfriend 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB39282569.444%

문제

Mark invited some people to join his social network. Some of them invited new people, who invited new people, and so on. Now there are N people in the network, numbered from 1 to N. Mark has decided to remove some people and keep others. There is one restriction: when removing a person, he will also remove the people s/he invited, and the people they invited, and so on. Mark will never remove himself, and we do not allow people to be invited by more than one person. Mark can also decide to not remove anyone.

How many different sets of people can be removed?

입력

The first line contains a single integer N (N ≤ 6), the number of people in the network. Next are N − 1 lines telling us who invited each person. To be precise, line i in this set (1 ≤ i ≤ N − 1) contains a single integer j (with j > i), which indicates that person j is the person who invited person i. Person N is Mark.

출력

Output a single integer, the number of possible sets of people that can be removed.

제한

예제 입력 1

3
3
3

예제 출력 1

4

예제 입력 2

4
3
4
4

예제 출력 2

6

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2011 > CCC 2011 Junior Division 5번

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

출처

대학교 대회

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

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