結果

問題 No.3 ビットすごろく
ユーザー mmmpppmmmppp
提出日時 2017-02-24 20:07:42
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 211 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 11,372 KB
実行使用メモリ 15,496 KB
最終ジャッジ日時 2023-08-30 23:07:10
合計ジャッジ時間 33,713 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,172 KB
testcase_01 AC 76 ms
15,260 KB
testcase_02 AC 76 ms
15,076 KB
testcase_03 AC 516 ms
15,156 KB
testcase_04 AC 114 ms
15,080 KB
testcase_05 AC 2,341 ms
15,152 KB
testcase_06 AC 626 ms
15,300 KB
testcase_07 AC 257 ms
15,252 KB
testcase_08 AC 1,505 ms
15,032 KB
testcase_09 AC 3,922 ms
15,200 KB
testcase_10 TLE -
testcase_11 AC 3,271 ms
15,248 KB
testcase_12 AC 2,201 ms
15,044 KB
testcase_13 AC 394 ms
15,288 KB
testcase_14 TLE -
testcase_15 TLE -
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{|j|
    next if r[j]!=i
    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