Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- import qualified Data.IntMap as M
- main :: IO ()
- main = do size <- getLine
- nodes <- getLine
- let tree = map read . words $ nodes :: [Int]
- m = M.fromList $ map (\x -> (x, 1 + fun1 (a M.! x))) tree
- a = M.fromList $ zip [0 ..] tree
- fun1 (-1) = 1
- fun1 i = m M.! i
- print $ maximum $ map fun1 tree
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement