結果

問題 No.3 ビットすごろく
ユーザー mazeppa1108mazeppa1108
提出日時 2015-06-04 22:47:46
言語 Haskell
(9.8.2)
結果
AC  
実行時間 232 ms / 5,000 ms
コード長 725 bytes
コンパイル時間 12,783 ms
コンパイル使用メモリ 192,528 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2023-09-13 23:12:57
合計ジャッジ時間 13,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,336 KB
testcase_01 AC 3 ms
7,504 KB
testcase_02 AC 2 ms
7,304 KB
testcase_03 AC 23 ms
12,976 KB
testcase_04 AC 6 ms
9,888 KB
testcase_05 AC 72 ms
13,020 KB
testcase_06 AC 32 ms
13,096 KB
testcase_07 AC 22 ms
12,268 KB
testcase_08 AC 52 ms
13,040 KB
testcase_09 AC 122 ms
13,824 KB
testcase_10 AC 162 ms
13,916 KB
testcase_11 AC 102 ms
13,916 KB
testcase_12 AC 73 ms
12,892 KB
testcase_13 AC 23 ms
12,504 KB
testcase_14 AC 152 ms
13,824 KB
testcase_15 AC 222 ms
13,904 KB
testcase_16 AC 192 ms
13,852 KB
testcase_17 AC 212 ms
13,896 KB
testcase_18 AC 22 ms
12,384 KB
testcase_19 AC 222 ms
13,928 KB
testcase_20 AC 4 ms
8,888 KB
testcase_21 AC 3 ms
7,348 KB
testcase_22 AC 143 ms
13,908 KB
testcase_23 AC 222 ms
13,968 KB
testcase_24 AC 232 ms
13,872 KB
testcase_25 AC 222 ms
14,008 KB
testcase_26 AC 2 ms
7,308 KB
testcase_27 AC 22 ms
12,892 KB
testcase_28 AC 182 ms
13,908 KB
testcase_29 AC 102 ms
13,908 KB
testcase_30 AC 3 ms
7,612 KB
testcase_31 AC 2 ms
7,876 KB
testcase_32 AC 92 ms
13,564 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

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
0