結果

問題 No.660 家を通り過ぎないランダムウォーク問題
ユーザー cympfhcympfh
提出日時 2018-03-02 23:34:44
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 391 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 22,212 KB
最終ジャッジ日時 2023-09-04 13:52:23
合計ジャッジ時間 11,887 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
22,212 KB
testcase_01 AC 85 ms
15,260 KB
testcase_02 AC 84 ms
15,080 KB
testcase_03 AC 83 ms
15,208 KB
testcase_04 AC 84 ms
15,268 KB
testcase_05 AC 84 ms
15,120 KB
testcase_06 AC 84 ms
15,164 KB
testcase_07 AC 84 ms
15,220 KB
testcase_08 AC 84 ms
15,244 KB
testcase_09 AC 86 ms
15,124 KB
testcase_10 AC 85 ms
15,128 KB
testcase_11 AC 84 ms
15,060 KB
testcase_12 AC 86 ms
15,132 KB
testcase_13 AC 85 ms
15,264 KB
testcase_14 AC 84 ms
15,120 KB
testcase_15 AC 84 ms
15,096 KB
testcase_16 AC 84 ms
15,124 KB
testcase_17 AC 87 ms
15,168 KB
testcase_18 AC 85 ms
15,048 KB
testcase_19 AC 85 ms
15,228 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(n)
  m = 2 * n
  ans = 0
  xs={}
  xs[0]=1
  m.times do
    ys = {}
    xs.keys.each do |x|
      if ys[x-1] == nil
        ys[x-1] = xs[x]
      else
        ys[x-1] += xs[x]
      end
      if ys[x+1] == nil
        ys[x+1] = xs[x]
      else
        ys[x+1] += xs[x]
      end
    end
    ans += ys[n] if ys[n] != nil
    xs = ys.clone
    xs[n] = 0
  end
  ans
end

p f(gets.to_i)
0