結果

問題 No.154 市バス
ユーザー lloyzlloyz
提出日時 2023-06-15 00:44:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 10,472 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-09-05 09:26:33
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 247 ms
7,916 KB
testcase_01 AC 243 ms
7,740 KB
testcase_02 AC 250 ms
7,720 KB
testcase_03 AC 207 ms
7,876 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,732 KB
testcase_06 AC 16 ms
7,824 KB
testcase_07 AC 265 ms
7,752 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    s = input()
    n = len(s)
    r = 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
        else:
            if not GR:
                break
    if r != 0 or not GR:
        print("impossible")
    else:
        print("possible")
0