結果

問題 No.154 市バス
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-02 23:54:22
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 442 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,756 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-08-03 10:00:19
合計ジャッジ時間 1,582 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
7,940 KB
testcase_01 AC 88 ms
7,852 KB
testcase_02 AC 86 ms
7,808 KB
testcase_03 AC 77 ms
7,916 KB
testcase_04 AC 87 ms
7,848 KB
testcase_05 AC 16 ms
7,820 KB
testcase_06 AC 17 ms
7,740 KB
testcase_07 AC 82 ms
7,796 KB
testcase_08 AC 16 ms
7,832 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 = input().strip()
    if solve(S):
        print('possible')
    else:
        print('impossible')
0