結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
mazeppa1108
|
| 提出日時 | 2015-06-04 22:47:46 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2,159 ms / 5,000 ms |
| コード長 | 725 bytes |
| コンパイル時間 | 8,425 ms |
| コンパイル使用メモリ | 202,880 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2024-07-01 07:24:17 |
| 合計ジャッジ時間 | 35,148 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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
ソースコード
import Data.Bits
import Control.Monad.State
import qualified Data.Vector.Unboxed as U
import Debug.Trace
import Data.List
main = do
n <- readLn
print $ evalState (bitDice [1] n) (1, U.fromList [])
bitDice :: [Int] -> Int -> State (Int, U.Vector Int) Int
bitDice [] _ = return $ -1
bitDice sl n = do
(c, visited) <- get
{-if k `U.elem` visited
then bitDice ks n --return $ [min c $ minimum $ evalState (bitDice ks n) (c, visited)-}
if n `elem` sl
then return c
else do
let
nexts x = filter (\y -> y > 0 && y <= n && y `U.notElem` visited) [x + popCount x, x - popCount x]
do
put (c + 1, visited U.++ U.fromList sl)
bitDice (nub . concat $ map nexts sl) n
mazeppa1108