結果

問題 No.154 市バス
ユーザー AEnAEn
提出日時 2022-05-16 11:18:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 936 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2023-10-12 03:21:59
合計ジャッジ時間 1,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
7,828 KB
testcase_01 AC 94 ms
7,904 KB
testcase_02 AC 94 ms
7,916 KB
testcase_03 AC 83 ms
7,820 KB
testcase_04 AC 94 ms
7,916 KB
testcase_05 AC 16 ms
7,968 KB
testcase_06 AC 16 ms
7,800 KB
testcase_07 AC 86 ms
7,812 KB
testcase_08 AC 16 ms
7,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(S):
    r, g, w, = 0, 0, 0
    for s in S[::-1]:
        if s == 'R':
            r += 1
        elif s == 'G':
            g += 1
            if g > r:
                return False
        elif g == 0:
            return False
        elif w < g:
            w += 1
    return w == g == r


T = int(input())
for t in range(T):
    S = list(input())
    if solve(S):
        print('possible')
    else:
        print('impossible')
0