結果
問題 | No.3 ビットすごろく |
ユーザー | Mr.Fuku |
提出日時 | 2018-06-24 20:05:08 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 612 bytes |
コンパイル時間 | 486 ms |
コンパイル使用メモリ | 10,752 KB |
実行使用メモリ | 8,668 KB |
最終ジャッジ日時 | 2023-09-13 13:46:11 |
合計ジャッジ時間 | 2,181 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,760 KB |
testcase_01 | AC | 16 ms
7,804 KB |
testcase_02 | AC | 16 ms
7,712 KB |
testcase_03 | RE | - |
testcase_04 | AC | 15 ms
8,064 KB |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | AC | 16 ms
8,248 KB |
testcase_08 | WA | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 15 ms
8,296 KB |
testcase_19 | RE | - |
testcase_20 | WA | - |
testcase_21 | AC | 15 ms
7,752 KB |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | AC | 15 ms
7,792 KB |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | WA | - |
testcase_31 | AC | 15 ms
7,768 KB |
testcase_32 | RE | - |
ソースコード
# coding: utf-8 # Your code here! n=int(input()) lst = [0]*(n+1) def f(num,cnt): if num==n: print(cnt) return True if num<1 or num > n: return False step = str(bin(num))[2:].count("1") fowd_n = num+step back_n = num-step if fowd_n<=n and lst[fowd_n]==0: if f(fowd_n,cnt+1): return True else: lst[fowd_n]=1 if back_n<=n and lst[back_n]==0: if f(back_n,cnt+1): return True else: lst[back_n]=1 return False lst[1]=1 if f(1,1)==False: print(-1)