結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
19,732 KB
testcase_01 AC 84 ms
15,136 KB
testcase_02 AC 75 ms
15,172 KB
testcase_03 AC 452 ms
15,280 KB
testcase_04 AC 112 ms
15,028 KB
testcase_05 AC 1,993 ms
15,128 KB
testcase_06 AC 543 ms
15,068 KB
testcase_07 AC 237 ms
15,144 KB
testcase_08 AC 1,284 ms
15,256 KB
testcase_09 AC 3,329 ms
15,328 KB
testcase_10 AC 4,667 ms
15,476 KB
testcase_11 AC 2,776 ms
15,352 KB
testcase_12 AC 1,892 ms
15,324 KB
testcase_13 AC 346 ms
15,156 KB
testcase_14 AC 4,376 ms
15,300 KB
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=Array.new(n,-1);r[0]=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 x>0&&r[x]<0
    r[y]=i+1 if y<n&&r[y]<0
  }
}
p r[n-1]
0