結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
kagami
|
| 提出日時 | 2019-07-14 18:44:14 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 597 bytes |
| 記録 | |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2026-09-29 04:43:50 |
| 合計ジャッジ時間 | 2,603 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 15 |
ソースコード
import sys
sys.setrecursionlimit(100000)
N = int(input())
visited = [-1] * N
def bfs(visited, now, ans):
if now == (N - 1):
return ans
visited[now] = 1
tmp = bin(now + 1)
count = 0
for i in tmp:
if i == '1':
count += 1
if now + count < N and visited[now + count] == -1:
return bfs(visited, now + count, ans + 1)
if 0 < now - count and visited[now - count] == -1:
return bfs(visited, now - count, ans + 1)
return -1
print(bfs(visited, 0, 1))
kagami