結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
AEn
|
| 提出日時 | 2022-05-13 16:49:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 68 ms / 5,000 ms |
| コード長 | 444 bytes |
| コンパイル時間 | 706 ms |
| コンパイル使用メモリ | 82,228 KB |
| 実行使用メモリ | 70,400 KB |
| 最終ジャッジ日時 | 2024-07-21 15:59:10 |
| 合計ジャッジ時間 | 3,408 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from collections import deque
N = int(input())
num = [-1]*N
seen = [False]*N
seen[0] = True
num[0] = 1
d = deque()
d.append(1)
while d:
n = d.popleft()
cnt = bin(n).count('1')
a, b = n+cnt-1, n-cnt-1
if 0<=a<N and seen[a] == False:
seen[a] = True
num[a] = num[n-1]+1
d.append(a+1)
if 0<=b<N and seen[b] == False:
seen[b] = True
num[b] = num[n-1]+1
d.append(b+1)
print(num[-1])
AEn