結果

問題 No.154 市バス
ユーザー lloyzlloyz
提出日時 2023-06-15 00:47:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-09-05 09:29:15
合計ジャッジ時間 3,125 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 282 ms
7,772 KB
testcase_01 AC 288 ms
7,884 KB
testcase_02 AC 293 ms
7,928 KB
testcase_03 AC 239 ms
7,892 KB
testcase_04 AC 287 ms
7,940 KB
testcase_05 AC 16 ms
7,788 KB
testcase_06 AC 16 ms
7,880 KB
testcase_07 AC 305 ms
7,844 KB
testcase_08 AC 16 ms
7,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    s = input()
    n = len(s)
    r = 0
    g = 0
    GR = False
    for i in range(n - 1, -1, -1):
        if s[i] == 'R':
            r += 1
        elif s[i] == 'G':
            r -= 1
            if r == -1:
                break
            GR = True
            g += 1
        else:
            if not GR:
                break
            if g > 0:
                g -= 1
    if r != 0 or g != 0 or not GR:
        print("impossible")
    else:
        print("possible")
0