結果

問題 No.3 ビットすごろく
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2018-06-16 16:15:36
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 4,430 ms
コンパイル使用メモリ 70,876 KB
実行使用メモリ 4,564 KB
最終ジャッジ日時 2023-09-13 06:06:53
合計ジャッジ時間 15,202 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 75 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 335 ms
4,376 KB
testcase_06 AC 93 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 316 ms
4,380 KB
testcase_13 AC 55 ms
4,376 KB
testcase_14 AC 704 ms
4,380 KB
testcase_15 AC 1,070 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 716 ms
4,380 KB
testcase_23 AC 1,102 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,376 KB
testcase_32 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 18) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import strutils, sequtils, intsets
proc trfm(i: int): int = i.toBin(16).count('1')
let
  N = stdin.readLine.parseInt
var
  arr = newSeq[int](N)
  ttl_S, mini_S1, mini_S2 = initIntSet()
  x = 1
mini_S1.incl 0
arr[0] = 1

proc go(x: int) =
  for i0 in mini_S1:
    var i = i0
    while true:
      let pre = i
      i += (i + 1).trfm * x
      if x == 1:
        if i >= N: break
      else:
        if i <= 0: break
      arr[i] = arr[pre] + 1
      if i notin ttl_S: mini_S2.incl i
      ttl_S.incl i
  if mini_S2.len == 0: echo -1; quit()
  swap(mini_S1, mini_S2)
  mini_S2.clear

while arr[^1] == 0:
  go(x)
  x *= -1

echo arr[^1]
0