結果

問題 No.154 市バス
ユーザー phtmscgphtmscg
提出日時 2019-05-13 20:00:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 998 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 7,964 KB
最終ジャッジ日時 2023-09-22 09:42:36
合計ジャッジ時間 3,982 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

for _ in range(int(input())):
    C = input()[::-1]
    cr,cg,cw = C.count("R"),C.count("G"),C.count("W")
    if cr == cg and cw >= cr:
        Q = [0,0]
        while C:
            color = C[0]
            C = C[1:]
            if color == "R":
                Q[0] += 1
            elif color == "G" and Q[0]>Q[1]:
                Q[1] += 1
            elif color == "G":
                print("impossible")
                break
            elif Q[0]*Q[1]==0 and color == "W":
                print("impossible")
                break
        else:
            print("possible")
    else:
        print("impossible")
0