結果
問題 | No.3 ビットすごろく |
ユーザー |
![]() |
提出日時 | 2017-03-21 02:49:09 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2,141 ms / 5,000 ms |
コード長 | 921 bytes |
コンパイル時間 | 6,135 ms |
コンパイル使用メモリ | 171,136 KB |
実行使用メモリ | 17,768 KB |
最終ジャッジ日時 | 2024-07-01 08:39:35 |
合計ジャッジ時間 | 31,906 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
importData.Arraytype Board = Array Int Intmain = don <- read <$> getLine :: IO IntputStrLn $ show $ calcMinDist nupdateBoard::IntBoard->IntBoardupdateBoard ([],b) = ([],b)updateBoard (is,b) =(is',(b//if b!i'<0 then [] else prev ++ next))where(_,n) = bounds bnumOfOne = sum . map (`mod`2) . takeWhile (>0) . iterate (`div`2)pr = i' - numOfOne i'nx = i' + numOfOne i'prev = if pr<1 || (b!pr>0&&b!pr<b!i'+1) then [] else [(pr,b!i'+1)]next = if nx>n || (b!nx>0&&b!nx<b!i'+1) then [] else [(nx,b!i'+1)](i',is') = findMinDistInd isfindMinDistInd [i] = (i,[])findMinDistInd (i:is) =let (i',is') = findMinDistInd is inif b!i'<0 || (b!i>=0 && b!i<=b!i') then (i,i':is') else (i',i:is')calcMinDist::Int->IntcalcMinDist n =snd (iterate updateBoard ([1..n],board)!!(n+1)) ! nwhereboard = listArray (1,n) $ 1:repeat (-1)