結果

問題 No.154 市バス
コンテスト
ユーザー steek79
提出日時 2015-10-14 15:38:48
言語 PyPy2
(7.3.15)
結果
MLE  
実行時間 -
コード長 653 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 137 ms
コンパイル使用メモリ 77,384 KB
最終ジャッジ日時 2025-12-03 17:31:32
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample MLE * 1
other MLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def check(str):
    if str.count('R') != str.count('G'):
        return 'impossible'
    elif str.count('W') < str.count('R'):
        return 'impossible'
    lines = [0] * str.count('R')
    for s in str:
        if s == 'W':
            if 0 not in lines:
                return 'impossible'
        elif s == 'G':
            try:
                lines[lines.index(0)] = 1
            except:
                return 'impossible'
        elif s == 'R':
            try:
                lines[lines.index(1)] = 2
            except:
                return 'impossible'

    return 'possible'

T = input()
for t in range(T):
    print check(raw_input())
0