結果

問題 No.154 市バス
コンテスト
ユーザー fine
提出日時 2016-01-15 01:34:50
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
WA  
実行時間 -
コード長 570 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 63 ms
コンパイル使用メモリ 9,088 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2026-04-30 16:48:13
合計ジャッジ時間 3,264 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

gets.to_i.times{
    s = gets.chomp
    g = s.count('G')
    r = s.count('R')
    w = s.count('W')
    if g != r || w < g
        puts "impossible"
    else
        s.reverse =~ /R(.*?)G/
        if s[-1] != 'R' || s[0] != 'W' || $1.include?('W')
            puts "impossible"
        else
            s.delete!('W')
            g.times{
                s.gsub!(/G(.*?)R/){$1}
                }
                if s.include?('R')
                    puts "impossible"
                else
                    puts "possible"
                end
        end
    end
    }
0