結果

問題 No.3 ビットすごろく
ユーザー LeonardoneLeonardone
提出日時 2015-10-28 17:14:49
言語 Haskell
(9.8.2)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 611 bytes
コンパイル時間 6,909 ms
コンパイル使用メモリ 165,852 KB
実行使用メモリ 12,172 KB
最終ジャッジ日時 2023-09-13 23:26:47
合計ジャッジ時間 8,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,448 KB
testcase_01 AC 3 ms
7,500 KB
testcase_02 AC 3 ms
7,436 KB
testcase_03 AC 4 ms
8,900 KB
testcase_04 AC 3 ms
7,880 KB
testcase_05 AC 12 ms
10,868 KB
testcase_06 AC 5 ms
9,156 KB
testcase_07 AC 4 ms
8,332 KB
testcase_08 AC 6 ms
10,160 KB
testcase_09 AC 12 ms
12,016 KB
testcase_10 AC 12 ms
11,996 KB
testcase_11 AC 12 ms
12,016 KB
testcase_12 AC 6 ms
10,836 KB
testcase_13 AC 4 ms
8,860 KB
testcase_14 AC 12 ms
12,036 KB
testcase_15 AC 10 ms
12,172 KB
testcase_16 AC 12 ms
12,036 KB
testcase_17 AC 12 ms
12,060 KB
testcase_18 AC 4 ms
8,468 KB
testcase_19 AC 12 ms
12,052 KB
testcase_20 AC 3 ms
7,784 KB
testcase_21 AC 3 ms
7,412 KB
testcase_22 AC 12 ms
11,960 KB
testcase_23 AC 12 ms
12,036 KB
testcase_24 AC 12 ms
11,976 KB
testcase_25 AC 12 ms
11,996 KB
testcase_26 AC 3 ms
7,324 KB
testcase_27 AC 4 ms
8,796 KB
testcase_28 AC 13 ms
11,988 KB
testcase_29 AC 12 ms
11,960 KB
testcase_30 AC 3 ms
7,488 KB
testcase_31 AC 3 ms
7,588 KB
testcase_32 AC 7 ms
11,404 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 #

-- yukicoder My Practice
-- author: Leonardone @ NEETSDKASU

import Data.Array
import Data.Bits (popCount)
import qualified Data.Set as Set

main = do
    n <- return . read =<< getLine
    print $ solve [1] [] n 1 Set.empty $ listArray (1, n) [(popCount (x::Int)) | x <- [1..n]]

solve [] [] _ _ _ _ = -1
solve [] nx g c st a = solve nx [] g (c + 1) st a
solve (b:bs) nx g c st a
    | b < 1 || b > g || Set.member b st = solve bs nx g c st a
    | b == g = c
    | otherwise =
        let
            x = a ! b
            st2 = Set.insert b st
        in
            solve bs ((b + x):((b - x):nx)) g c st2 a
0