| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 34 | 22 | 14 | 77.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.
A single line with the integer that is the largest number of pastures that can be visited on a legal stroll.
5 2 4 5 5 2
3