結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 15 ms
7,840 KB
testcase_06 AC 15 ms
7,940 KB
testcase_07 AC 201 ms
7,828 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

ans = ["impossible", "possible"]

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

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