結果

問題 No.1133 キムワイプイーター
ユーザー shi-moshi-mo
提出日時 2020-09-29 00:26:32
言語 Ruby
(3.3.0)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 11,404 KB
実行使用メモリ 63,316 KB
最終ジャッジ日時 2023-09-15 20:18:23
合計ジャッジ時間 11,049 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,128 KB
testcase_01 AC 83 ms
15,016 KB
testcase_02 AC 200 ms
27,748 KB
testcase_03 AC 390 ms
48,556 KB
testcase_04 AC 398 ms
50,036 KB
testcase_05 AC 410 ms
51,828 KB
testcase_06 AC 400 ms
50,296 KB
testcase_07 AC 275 ms
36,620 KB
testcase_08 AC 192 ms
27,432 KB
testcase_09 AC 378 ms
46,300 KB
testcase_10 AC 530 ms
63,316 KB
testcase_11 AC 496 ms
58,956 KB
testcase_12 AC 409 ms
51,112 KB
testcase_13 AC 491 ms
58,656 KB
testcase_14 AC 389 ms
48,096 KB
testcase_15 AC 263 ms
34,960 KB
testcase_16 AC 196 ms
27,744 KB
testcase_17 AC 87 ms
15,468 KB
testcase_18 AC 142 ms
15,796 KB
testcase_19 AC 110 ms
15,296 KB
testcase_20 AC 91 ms
15,624 KB
testcase_21 AC 94 ms
16,036 KB
testcase_22 AC 96 ms
15,824 KB
testcase_23 AC 80 ms
15,140 KB
testcase_24 AC 80 ms
15,248 KB
testcase_25 AC 86 ms
15,520 KB
testcase_26 AC 80 ms
15,112 KB
testcase_27 AC 79 ms
15,132 KB
testcase_28 AC 80 ms
15,076 KB
testcase_29 AC 79 ms
15,212 KB
testcase_30 AC 97 ms
15,856 KB
testcase_31 AC 82 ms
15,076 KB
testcase_32 AC 81 ms
15,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, _ = gets.split.map(&:to_i)
s = gets.chomp!.split(//)

mat = Array.new(n+1){ [1] * (n+1) }
mat[0][0] = 0
pos = { x: 0, y: 0 }
s.each do |c|
  case c
  when 'U'
    pos[:y] += 1
  when 'R'
    pos[:x] += 1
  when 'L'
    pos[:x] -= 1
  when 'D'
    pos[:y] -= 1
  else
    raise 'must not happen'
  end
  mat[ pos[:y] ][ pos[:x] ] = 0
end

n.downto(0) do |i|
  puts mat[i].join(' ')
end
0