結果

問題 No.154 市バス
ユーザー steek79steek79
提出日時 2015-10-14 16:30:00
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 08:50:24
合計ジャッジ時間 1,150 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 11 ms
6,940 KB
testcase_06 AC 11 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 11 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(str):
    if str.count('W') >= str.count('R') == str.count('G') > 0:
        cnt_w = cnt_g = cnt_r = 0
        coming_green = False
        coming_red = 0
        for s in str:
            if s == 'W':
                coming_green = True
                cnt_w += 1
            elif s == 'G':
                if coming_green > 0 and cnt_w > cnt_g:
                    coming_green = False
                    coming_red += 1
                    cnt_g += 1
                else:
                    return 'impossible'
            elif s == 'R':
                if coming_red > 0 and cnt_g > cnt_r:
                    coming_red -= 1
                    cnt_r += 1
                else:
                    return 'impossible' 
    else: return 'impossible' 
    
    #print coming_green, coming_red
    if coming_green == coming_red == 0: 
        return 'possible'
    else: 
        return 'impossible' 
                
T = input()
for t in range(T):
    print check(raw_input())
0