結果

問題 No.154 市バス
ユーザー ntuda
提出日時 2024-01-05 00:19:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 452 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-27 18:54:26
合計ジャッジ時間 3,794 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

for j in range(int(input())):
    #print(j)
    W,R,G = 0,0,0
    lastw = 0
    lastg = 0
    S = input()
    for i,s in enumerate(S):
        if s == "W":
            W += 1
            lastw = i
        if s == "R":
            R += 1
        if s == "G":
            G += 1
            lastg = i
        if W < G or G < R:
            print("impossible")
            break

    else:
        if lastw > lastg:
            print("impossible")
            continue
        if R == G and R > 0:
            print("possible")
        else:
            print("impossible")
0