結果
問題 | No.3 ビットすごろく |
ユーザー | neko |
提出日時 | 2019-11-03 11:28:51 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 514 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 10,888 KB |
実行使用メモリ | 9,192 KB |
最終ジャッジ日時 | 2023-10-13 01:45:54 |
合計ジャッジ時間 | 2,706 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 22 ms
8,980 KB |
testcase_03 | AC | 22 ms
8,928 KB |
testcase_04 | WA | - |
testcase_05 | AC | 22 ms
9,084 KB |
testcase_06 | AC | 22 ms
9,088 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 22 ms
9,100 KB |
testcase_13 | AC | 22 ms
8,976 KB |
testcase_14 | AC | 23 ms
9,020 KB |
testcase_15 | AC | 23 ms
9,144 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 22 ms
9,024 KB |
testcase_23 | AC | 23 ms
9,044 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 22 ms
8,976 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
import queue #移動するマス数を求める関数 def calcpop(num): return bin(num).count("1") N=int(input()) q=queue.Queue() q.put(1) masu =[] masu=[-1]*(N+10) masu[1]=1 while q.empty(): curpos=q.get() popcnt=calcpop(curpos) if (curpos-popcnt>0 and masu[curpos-popcnt]==-1): masu[curpos-popcnt]=masu[curpos]+1 q.put(curpos-popcnt) if (curpos+popcnt<=N and masu[curpos+popcnt]==-1): masu[curpos+popcnt]=masu[curpos]+1 q.put(curpos+popcnt) print(masu[N])