結果

問題 No.154 市バス
ユーザー ebicochineal
提出日時 2016-06-20 17:57:55
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-10-13 08:35:15
合計ジャッジ時間 3,038 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

for i in range(int(input())):
    s = input()
    w, g, r, l = 0, 0, 0, s.count("G")
    f = 1 if s[0] != "W" else 0
    for j in s:
        if j == "W":
            w += 1
            if l == 0:
                f = 1
        if j == "G":
            if l > 0 and w > 0:
                w -= 1; l -= 1; g += 1
            else:
                f = 1
        if j == "R":
            if g > 0:
                g -= 1; r += 1
            else:
                f = 1
        if f : break
    print("possible" if f == 0 and g == 0 else "impossible")
0