結果

問題 No.154 市バス
ユーザー neko_the_shadowneko_the_shadow
提出日時 2016-12-03 21:44:15
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 313 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-04-21 10:01:54
合計ジャッジ時間 10,835 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,281 ms
15,744 KB
testcase_01 AC 1,298 ms
15,872 KB
testcase_02 AC 1,297 ms
15,488 KB
testcase_03 WA -
testcase_04 AC 1,172 ms
15,744 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(line)
  until line.count("G").zero? && line.count("R")
    g,r = ["G", "R"].map{|bus| line.index(bus)}
    return "impossible" if [g, r].include?(nil) || g > r || line[0..g].count("W").zero?
    ["G", "R", "W"].each{|bus| line.sub!(bus, "")}
  end
  "possible"
end

puts $<.drop(1).map{|line| f(line.chomp)}
0