結果
問題 | No.3 ビットすごろく |
ユーザー | papinnie |
提出日時 | 2019-09-19 17:26:14 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 562 bytes |
コンパイル時間 | 131 ms |
コンパイル使用メモリ | 10,980 KB |
実行使用メモリ | 29,996 KB |
最終ジャッジ日時 | 2023-09-26 14:58:11 |
合計ジャッジ時間 | 8,771 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
29,612 KB |
testcase_01 | AC | 127 ms
29,484 KB |
testcase_02 | AC | 125 ms
29,624 KB |
testcase_03 | AC | 131 ms
29,568 KB |
testcase_04 | AC | 128 ms
29,680 KB |
testcase_05 | AC | 141 ms
29,664 KB |
testcase_06 | AC | 136 ms
29,516 KB |
testcase_07 | AC | 132 ms
29,628 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 134 ms
29,764 KB |
testcase_13 | AC | 131 ms
29,696 KB |
testcase_14 | AC | 141 ms
29,776 KB |
testcase_15 | AC | 142 ms
29,752 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 133 ms
29,644 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 126 ms
29,608 KB |
testcase_22 | AC | 141 ms
29,636 KB |
testcase_23 | AC | 141 ms
29,736 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 128 ms
29,676 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 131 ms
29,612 KB |
testcase_32 | WA | - |
ソースコード
from collections import deque import numpy as np N = int(input()) moves = [bin(x).count('1') for x in range(N+1)] routes = [] reachables = np.zeros(N+1, dtype=bool) q = deque([(1,1)]) while(len(q)): n, c = q.pop() reachables[n] = True if n == N: routes.append(c) else: back, go = -1 * moves[n] + n, moves[n] + n for target in [back, go]: if (1 < target <= N) and not reachables[target]: q.append((target, c+1)) if len(routes) == 0: print(-1) # unreachable else: print(max(routes))