結果
問題 | No.3 ビットすごろく |
ユーザー |
|
提出日時 | 2020-06-22 18:21:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 631 bytes |
コンパイル時間 | 128 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-07-03 18:44:08 |
合計ジャッジ時間 | 2,137 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 WA * 1 |
ソースコード
from collections import dequen = int(input())l = n.bit_length()g = [[] for _ in range(n + 1 + l)]for i in range(n + 1):x = bin(i).count("1")g[i].append(i + x)g[i].append(i - x)par = [0] * (n + 1 + l)chk = [False] * (n + 1 + l)chk[0] = Truestk = deque()stk.append(1)while stk:v = stk.popleft()for y in g[v]:if chk[y]:continueif y == par[v]:continuechk[y] = Truepar[y] = vstk.append(y)if not chk[n]:print(-1)exit()cnt = 1while n > 1:n = par[n]cnt += 1print(cnt)#print(chk)#print(g)#print(par)