結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-12 09:44:57 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 1,149 bytes |
| 記録 | |
| コンパイル時間 | 307 ms |
| コンパイル使用メモリ | 21,468 KB |
| 実行使用メモリ | 15,920 KB |
| 最終ジャッジ日時 | 2026-09-03 17:10:47 |
| 合計ジャッジ時間 | 8,000 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 1 -- * 29 |
ソースコード
# -*- coding: utf-8 -*-
import sys
import math
import copy
def main():
text = sys.stdin.readline()
goal = int(text) #ゴール
path = [1] #経路記録用
stack = [path]
#経路探索処理→深さ優先探索、ゴールに到達した時点で終了
while len(stack) > 0:
path = stack.pop(-1)
#行先判定処理
next_position_list = nextGoto(path[-1])
for p in next_position_list:
if p == goal:
path.append(p)
#print(path,len(path))
print(len(path))
return
elif p < 1 or p > goal:
continue
elif p in path:
continue
else:
buf_path = copy.deepcopy(path)
buf_path.append(p)
stack.append(buf_path)
print(-1)
return
#行先返答関数
def nextGoto(arg_position):
binary_text = bin(arg_position)
steps = len(binary_text.replace("0b","").replace("0",""))
goto = [arg_position - steps, arg_position + steps]
return goto
if __name__ == "__main__":
main()