結果

問題 No.3 ビットすごろく
ユーザー mmmpppmmmppp
提出日時 2017-02-24 20:14:50
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,248 ms / 5,000 ms
コード長 246 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 11,344 KB
実行使用メモリ 15,520 KB
最終ジャッジ日時 2023-09-14 00:24:14
合計ジャッジ時間 19,204 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,056 KB
testcase_01 AC 84 ms
15,268 KB
testcase_02 AC 82 ms
15,304 KB
testcase_03 AC 167 ms
15,344 KB
testcase_04 AC 92 ms
15,188 KB
testcase_05 AC 442 ms
15,176 KB
testcase_06 AC 182 ms
15,064 KB
testcase_07 AC 119 ms
15,300 KB
testcase_08 AC 307 ms
15,280 KB
testcase_09 AC 664 ms
15,324 KB
testcase_10 AC 863 ms
15,440 KB
testcase_11 AC 578 ms
15,364 KB
testcase_12 AC 421 ms
15,176 KB
testcase_13 AC 144 ms
15,412 KB
testcase_14 AC 824 ms
15,256 KB
testcase_15 AC 1,228 ms
15,456 KB
testcase_16 AC 1,117 ms
15,340 KB
testcase_17 AC 1,195 ms
15,308 KB
testcase_18 AC 128 ms
15,160 KB
testcase_19 AC 1,248 ms
15,368 KB
testcase_20 AC 85 ms
15,228 KB
testcase_21 AC 80 ms
15,312 KB
testcase_22 AC 849 ms
15,500 KB
testcase_23 AC 1,246 ms
15,452 KB
testcase_24 AC 1,248 ms
15,328 KB
testcase_25 AC 1,221 ms
15,332 KB
testcase_26 AC 84 ms
15,192 KB
testcase_27 AC 154 ms
15,160 KB
testcase_28 AC 1,024 ms
15,520 KB
testcase_29 AC 590 ms
15,240 KB
testcase_30 AC 83 ms
15,292 KB
testcase_31 AC 84 ms
15,304 KB
testcase_32 AC 523 ms
15,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i+1
a=(0..n).map{|i|i.to_s(2).count ?1};a[0]=1
r=Array.new(n,-1);r[0]=0
n.times{|i|
  break if !r.include?(i)
  n.times{|j|
    next if r[j]!=i
    x,y=j-a[j],j+a[j]
    r[x]=i+1 if x>0&&r[x]<0
    r[y]=i+1 if y<n&&r[y]<0
  }
}
p r[n-1]
0