結果

問題 No.154 市バス
ユーザー ebicochineal
提出日時 2016-06-20 10:24:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-13 08:35:04
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.count("G") != s.count("R") or s[0] != "W" else 0
    for j in s:
        if f > 0 : break 
        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
    print("possible" if f == 0 and r == s.count("G") else "impossible")
0