- 10 名前:デフォルトの名無しさん [2017/01/16(月) 21:52:49.11 ID:e08JNJ9T.net]
- 前スレで質問しようとして何か変な風に失敗してしまいました...
再掲させてください ---- aojの問題でわからないところがあるので質問します. judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0033 二股にわかれた容器に1から10まで番号のついたボールを番号の大小関係の制約を守って並べていけるかを判定する問題なんですが,自分のコードを提出するとruntime errorになってしまいます. 理由も考えたんですがよくわからないので,何がダメなのかアドバイスをお願いしたいです. main :: IO () main = getContents >>= mapM_ (putStrLn . (\arr -> solve (tail arr) 0 (head arr, 0)) . map (read :: String -> Int) . words) . tail . lines solve :: [Int] -> Int -> (Int, Int) -> String solve arr index (box1, box2) | index == length arr = "YES" | otherwise = if box1 < box2 then solve arr index (box2, box1) else if arr !! index > box1 then solve arr (index + 1) (arr !! index, box2) else if arr !! index > box2 then solve arr (index + 1) (box1, arr !! index) else "NO"
|

|