結果

問題 No.2240 WAC
ユーザー siman
提出日時 2023-03-12 10:13:35
言語 Ruby
(3.4.1)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-09-18 06:56:40
合計ジャッジ時間 6,472 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
S = gets.chomp

a_pos = []
w_pos = []

S.each_char.with_index do |s, i|
  case s
  when 'W'
    w_pos << i
  when 'A'
    a_pos << i
  else
    if a_pos.empty?
      puts 'No'
      exit
    else
      a_pos.shift
    end
  end
end

until w_pos.empty?
  l = w_pos.shift

  if a_pos[0] < l
    puts 'No'
    exit
  else
    a_pos.shift
  end
end

puts 'Yes'
0