結果
問題 | No.3 ビットすごろく |
ユーザー |
![]() |
提出日時 | 2016-03-08 23:54:32 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 948 ms / 5,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 7,168 KB |
最終ジャッジ日時 | 2024-07-01 07:47:02 |
合計ジャッジ時間 | 13,044 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
# -*- coding: utf-8 -*-from collections import Counterfrom collections import dequeN = input()Blist = [ 0 for i in range(N)]for i in range(N):tmp = Counter(bin(i+1))Blist[i] = tmp["1"]#幅優先探索openlist = deque()closelist = deque()cntlist = deque()rlist = deque()openlist.append(0)cntlist.append(1)while len(openlist) != 0:point = openlist.popleft()cnt = cntlist.popleft()if point == N-1:print cntexit()elif -1 < point < N-1 and closelist.count(point) == 0:cnt += 1openlist.append(point + Blist[point])openlist.append(point - Blist[point])closelist.append(point)cntlist.append(cnt)cntlist.append(cnt)print -1