結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 75 ms
15,156 KB
testcase_03 AC 447 ms
15,104 KB
testcase_04 WA -
testcase_05 AC 1,956 ms
15,044 KB
testcase_06 AC 546 ms
15,312 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1,895 ms
15,316 KB
testcase_13 WA -
testcase_14 WA -
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 a[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