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

27074번 - Strolling Cows 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB34221477.778%

문제

Before going to the barn for dinner, the cows like to stroll the N (1 ≤ N ≤ 30,000) pastures while watching the sun set. Each pasture leads to precisely one pasture, though some pastures have more than one pasture emptying into them. For a valid strolling experience, the cows can start in any pasture and must finish in that same pasture without visiting any other pasture twice. Given a description of the pasture paths, deduce the longest possible valid stroll the cows can take.

입력

  • Line 1: One integer: N
  • Lines 2..N+1: Line M tells the pasture number that pasture M-1 connects to (so line 2 tells which pasture is accessible from pasture 1, etc.)

출력

A single line with the integer that is the largest number of pastures that can be visited on a legal stroll.

제한

예제 입력 1

5
2
4
5
5
2

예제 출력 1

3

힌트

출처

Olympiad > USA Computing Olympiad > 2002-2003 Season > USACO Winter 2002 Contest > Green 3번

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

출처

대학교 대회

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

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