結果

問題 No.3 ビットすごろく
ユーザー mmmpppmmmppp
提出日時 2017-02-24 20:02:20
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 214 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 11,392 KB
実行使用メモリ 30,680 KB
最終ジャッジ日時 2023-08-30 23:05:30
合計ジャッジ時間 18,051 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
30,680 KB
testcase_01 AC 78 ms
15,172 KB
testcase_02 AC 82 ms
15,120 KB
testcase_03 AC 594 ms
15,552 KB
testcase_04 AC 123 ms
15,060 KB
testcase_05 AC 2,684 ms
15,320 KB
testcase_06 AC 719 ms
15,216 KB
testcase_07 AC 290 ms
15,040 KB
testcase_08 AC 1,701 ms
15,564 KB
testcase_09 AC 4,511 ms
15,232 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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