結果

問題 No.3 ビットすごろく
ユーザー LeonardoneLeonardone
提出日時 2015-10-28 17:22:00
言語 Haskell
(9.8.2)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 11,470 ms
コンパイル使用メモリ 168,100 KB
実行使用メモリ 12,100 KB
最終ジャッジ日時 2023-09-13 23:27:39
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,476 KB
testcase_01 AC 3 ms
7,404 KB
testcase_02 AC 2 ms
7,408 KB
testcase_03 AC 5 ms
8,876 KB
testcase_04 AC 3 ms
7,928 KB
testcase_05 AC 7 ms
10,984 KB
testcase_06 AC 5 ms
9,072 KB
testcase_07 AC 4 ms
8,380 KB
testcase_08 AC 6 ms
10,144 KB
testcase_09 AC 12 ms
12,056 KB
testcase_10 AC 12 ms
11,956 KB
testcase_11 AC 12 ms
12,048 KB
testcase_12 AC 7 ms
10,748 KB
testcase_13 AC 4 ms
8,724 KB
testcase_14 AC 12 ms
12,040 KB
testcase_15 AC 12 ms
12,052 KB
testcase_16 AC 12 ms
12,048 KB
testcase_17 AC 12 ms
12,036 KB
testcase_18 AC 4 ms
8,576 KB
testcase_19 AC 12 ms
12,100 KB
testcase_20 AC 3 ms
7,776 KB
testcase_21 AC 3 ms
7,432 KB
testcase_22 AC 12 ms
12,016 KB
testcase_23 AC 12 ms
12,012 KB
testcase_24 AC 12 ms
11,972 KB
testcase_25 AC 12 ms
12,036 KB
testcase_26 AC 3 ms
7,416 KB
testcase_27 AC 5 ms
8,940 KB
testcase_28 AC 12 ms
11,996 KB
testcase_29 AC 12 ms
12,092 KB
testcase_30 AC 3 ms
7,588 KB
testcase_31 AC 3 ms
7,500 KB
testcase_32 AC 12 ms
11,408 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 <- readLn
    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