結果

問題 No.154 市バス
ユーザー finefine
提出日時 2016-01-17 22:30:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 441 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-21 09:07:20
合計ジャッジ時間 3,721 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 441 ms
13,440 KB
testcase_01 AC 420 ms
13,312 KB
testcase_02 AC 422 ms
13,440 KB
testcase_03 AC 197 ms
13,440 KB
testcase_04 AC 406 ms
12,544 KB
testcase_05 AC 93 ms
12,288 KB
testcase_06 AC 87 ms
12,288 KB
testcase_07 AC 441 ms
13,440 KB
testcase_08 AC 90 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

gets.to_i.times{
    s = gets.chomp
    s.reverse =~ /R(.*?)G/
    tmp = s.count('G')
    if s[-1] != 'R' || s[0] != 'W' || $1.to_s.include?('W') || tmp != s.count('R') 
        puts "impossible"
    else
        flag = 0
        w = []
        g = []
        r = []
        s.length.times{|i|
            case s[i]
                when 'W'
                w.push(i)
                when 'G'
                g.push(i)
                when 'R'
                r.push(i)
            end
            }
        tmp.times{|i|
            if g[i] > r[i] || w[i] > g[i]
                flag = 1
            end
             }
        puts ["possible","impossible"][flag]
    end
    }
0