結果

問題 No.154 市バス
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2015-07-28 18:18:11
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 612 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 28,096 KB
最終ジャッジ日時 2024-04-21 08:45:20
合計ジャッジ時間 6,656 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

# Here your code !
def possible?(s)
    lines = []
    s.chars.reverse.find {|c|
        if c == 'R'
            lines << 2
            false
        elsif c == 'G'
            redpos = lines.index(2)
            if redpos
                lines[redpos] = 1
                lines.sort!
            end
            !redpos
        else
            wgpos = lines.index {|v| v < 2}
            if wgpos
                lines[wgpos] = 0 
                lines.sort!
            end
            !wgpos
        end
    }.nil?
end

n = gets.to_i
n.times do
    puts possible?(gets.chomp) ? "possible" : "impossible"
end
0