結果

問題 No.154 市バス
ユーザー ayaoniayaoni
提出日時 2020-11-27 14:33:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-10-01 04:11:29
合計ジャッジ時間 2,115 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 193 ms
7,808 KB
testcase_01 AC 192 ms
7,840 KB
testcase_02 AC 193 ms
7,744 KB
testcase_03 AC 152 ms
7,752 KB
testcase_04 AC 178 ms
7,932 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 188 ms
7,756 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()


T = I()
for _ in range(T):
    U = S()
    r,g,w = 0,0,0
    for u in U:
        if u == 'R':
            if g > 0:
                g -= 1
            else:
                print('impossible')
                break
        elif u == 'G':
            if w > 0:
                w -= 1
                g += 1
            else:
                print('impossible')
                break
        else:
            w += 1
    else:
        if g == 0:
            print('possible')
        else:
            print('impossible')
0