結果
問題 | No.3 ビットすごろく |
ユーザー | Woo-Cie |
提出日時 | 2019-03-23 02:34:35 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 622 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 11,884 KB |
実行使用メモリ | 43,068 KB |
最終ジャッジ日時 | 2023-10-19 20:15:31 |
合計ジャッジ時間 | 21,402 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 484 ms
42,804 KB |
testcase_03 | AC | 509 ms
42,804 KB |
testcase_04 | WA | - |
testcase_05 | AC | 520 ms
42,800 KB |
testcase_06 | AC | 504 ms
42,804 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 508 ms
43,068 KB |
testcase_13 | AC | 498 ms
42,804 KB |
testcase_14 | AC | 518 ms
42,804 KB |
testcase_15 | AC | 539 ms
42,804 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 539 ms
42,804 KB |
testcase_23 | AC | 549 ms
42,804 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
#!/usr/bin/env python3 # -*- coding: utf-8-*- import queue import numpy as np if __name__ == '__main__': n = int(input()) q = queue.Queue() q.put((1, 0)) tbl = np.zeros((n)) tbl[0] = 1 while not q.empty(): i, t = q.get() if i == n: print(t) exit() tt = i d = 0 while tt > 0: d += tt%2 tt //= 2 if i - d > 0 and tbl[i-d-1] == 0: q.put((i-d, t+1)) tbl[i-d-1] = 1 if i + d <= n and tbl[i+d-1] == 0: q.put((i+d, t+1)) tbl[i+d-1] = 1 print("-1")