結果

問題 No.154 市バス
ユーザー irumo8202irumo8202
提出日時 2022-01-22 17:40:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 355 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 10,652 KB
実行使用メモリ 7,964 KB
最終ジャッジ日時 2023-08-18 11:42:53
合計ジャッジ時間 2,031 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
7,728 KB
testcase_01 AC 151 ms
7,860 KB
testcase_02 AC 152 ms
7,816 KB
testcase_03 AC 154 ms
7,812 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 166 ms
7,856 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

ans = ["impossible", "possible"]

for _ in range(N):
    S = input()
    rcnt = 0
    gcnt = 0

    flg = True
    for s in S[::-1]:
        if s == "R":
            rcnt += 1
        elif s == "G":
            gcnt += 1
            if gcnt > rcnt:
                flg = False
    if rcnt != gcnt:
        flg = False
    print(ans[flg])
0