結果

問題 No.3 ビットすごろく
ユーザー myuonmyuon
提出日時 2015-03-09 08:05:18
言語 Haskell
(9.8.2)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 544 bytes
コンパイル時間 8,231 ms
コンパイル使用メモリ 162,140 KB
実行使用メモリ 11,760 KB
最終ジャッジ日時 2023-09-06 22:33:34
合計ジャッジ時間 11,183 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,072 KB
testcase_01 AC 2 ms
7,120 KB
testcase_02 AC 3 ms
7,168 KB
testcase_03 AC 42 ms
11,532 KB
testcase_04 AC 6 ms
8,256 KB
testcase_05 AC 142 ms
11,596 KB
testcase_06 AC 42 ms
11,440 KB
testcase_07 AC 22 ms
10,960 KB
testcase_08 AC 92 ms
11,460 KB
testcase_09 AC 222 ms
11,632 KB
testcase_10 AC 312 ms
11,560 KB
testcase_11 AC 182 ms
11,540 KB
testcase_12 AC 132 ms
11,516 KB
testcase_13 AC 32 ms
11,324 KB
testcase_14 AC 292 ms
11,600 KB
testcase_15 AC 432 ms
11,752 KB
testcase_16 AC 382 ms
11,664 KB
testcase_17 AC 422 ms
11,724 KB
testcase_18 AC 32 ms
11,284 KB
testcase_19 AC 442 ms
11,620 KB
testcase_20 AC 5 ms
7,856 KB
testcase_21 AC 2 ms
7,168 KB
testcase_22 AC 292 ms
11,660 KB
testcase_23 AC 442 ms
11,760 KB
testcase_24 AC 443 ms
11,724 KB
testcase_25 AC 432 ms
11,668 KB
testcase_26 RE -
testcase_27 AC 32 ms
11,404 KB
testcase_28 AC 362 ms
11,668 KB
testcase_29 AC 193 ms
11,508 KB
testcase_30 AC 2 ms
7,220 KB
testcase_31 AC 3 ms
7,360 KB
testcase_32 AC 162 ms
11,548 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 Control.Applicative
import Data.List
import Data.Bits (popCount)

solve n = (\x -> if last x == [] then -1 else 1+length x) $ unfoldr next (1,[[1]]) where
  next :: (Int,[[Int]]) -> Maybe ([Int],(Int,[[Int]]))
  next (m,h'@(h:hs))
    | n `elem` h || h == [] = Nothing
    | otherwise = let k = nub $ h >>= flip step h' in Just (k,(m+1,k:h'))

  step :: Int -> [[Int]] -> [Int]
  step j hs = [i|i<-fmap ((j+) . (*popCount j)) [1,-1], 1<=i, i<=n, all (notElem i) hs]

main = do
  n <- (read :: String -> Int) <$> getLine
  print $ solve n
0