結果

問題 No.3 ビットすごろく
ユーザー 34056915823405691582
提出日時 2017-01-21 14:47:54
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4,921 ms / 5,000 ms
コード長 646 bytes
コンパイル時間 5,881 ms
コンパイル使用メモリ 158,492 KB
実行使用メモリ 16,436 KB
最終ジャッジ日時 2023-09-14 00:22:48
合計ジャッジ時間 53,644 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,020 KB
testcase_01 AC 2 ms
7,076 KB
testcase_02 AC 2 ms
7,008 KB
testcase_03 AC 242 ms
13,496 KB
testcase_04 AC 32 ms
10,824 KB
testcase_05 AC 1,322 ms
15,572 KB
testcase_06 AC 312 ms
14,276 KB
testcase_07 AC 102 ms
11,068 KB
testcase_08 AC 812 ms
15,424 KB
testcase_09 AC 2,292 ms
15,248 KB
testcase_10 AC 3,301 ms
16,088 KB
testcase_11 AC 1,892 ms
14,636 KB
testcase_12 AC 1,282 ms
16,000 KB
testcase_13 AC 182 ms
11,908 KB
testcase_14 AC 3,052 ms
14,236 KB
testcase_15 AC 4,761 ms
16,436 KB
testcase_16 AC 4,042 ms
16,120 KB
testcase_17 AC 4,571 ms
15,968 KB
testcase_18 AC 132 ms
11,640 KB
testcase_19 AC 4,862 ms
16,324 KB
testcase_20 AC 22 ms
8,844 KB
testcase_21 AC 2 ms
7,016 KB
testcase_22 AC 2,982 ms
14,036 KB
testcase_23 AC 4,921 ms
16,428 KB
testcase_24 AC 4,902 ms
16,380 KB
testcase_25 AC 4,781 ms
16,016 KB
testcase_26 AC 3 ms
6,956 KB
testcase_27 AC 212 ms
14,252 KB
testcase_28 AC 3,882 ms
16,052 KB
testcase_29 AC 1,932 ms
15,132 KB
testcase_30 AC 2 ms
7,100 KB
testcase_31 AC 4 ms
7,256 KB
testcase_32 AC 1,662 ms
15,156 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.Array

numOfOne 0 = 0
numOfOne n = mod n 2 + numOfOne (div n 2)
prev i = i - numOfOne i
next i = i + numOfOne i

type Board = Array Int Int
update :: Board -> Board
update b = foldl update' b [first..last] where
  (first,last) = bounds b
  update' b' i =
    let
      b'' = if prev i >= first && b!i+1 < b'!prev i then b'//[(prev i,b!i+1)] else b'
      b''' = if next i <= last && b!i+1 < b''!next i then b''//[(next i,b!i+1)] else b''
    in
      b'''

main = do
  n <- fmap read getLine
  let
    b = (listArray (1,n) $ repeat (n+1))//[(1,1)]
    b' = (iterate update b)!!(n-1)
  putStrLn . show $ if b'!n < n+1 then b'!n else -1
0