結果

問題 No.154 市バス
ユーザー JunOnumaJunOnuma
提出日時 2017-05-19 14:42:02
言語 Python2
(2.7.18)
結果
AC  
実行時間 338 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 63 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-04-21 10:16:02
合計ジャッジ時間 2,811 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

t = int(raw_input())
for _ in range(t):
    l = list(raw_input())
    ans = True
    w = 0
    g = 0
    r = 0
    for c in l:
        if c == 'W':
            w += 1
        elif c == 'G':
            g += 1
            if g > w:
                ans = False
                break
        elif c == 'R':
            r += 1
            if r > g:
                ans = False
                break
    l.reverse()
    r = 0
    g = 0
    w = 0
    for c in l:
        if c == 'R':
            r += 1
        elif c == 'G':
            g += 1
            if g > r:
                ans = False
                break
        elif c == 'W':
            if g == 0:
                ans = False
                break
    if r != g:
        ans = False
    if ans:
        print 'possible'
    else:
        print 'impossible'
0