結果

問題 No.154 市バス
ユーザー TsubajiroTsubajiro
提出日時 2022-05-20 23:36:06
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 863 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-09-20 10:02:37
合計ジャッジ時間 4,566 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
tt=[]
for _ in range(T):
    tt.append(input())
for t in tt:
    t = list(t)
    if len(t)<3:
        print("impossible")
        continue
    countW=0
    countG=0
    countR=0
    Flag=True
    FlagW=False
    for i in t:
        if i=="G":
            countG+=1
        elif i=="R":
            countR+=1
            FlagW=True
        else:
            countW+=1
            FlagW=False

        if countG-countR<0:
            Flag=False
            continue
    countG2=0
    countW2=0
    countR2=0
    t.reverse()
    for i in t:
        if i=="G":
            countG2+=1
        elif i=="W":
            countW2+=1
        else:
            countR2+=1
        if countG2< countR2 and countG2<countW2:
            Flag=False


    if countG!=countR or not Flag or not FlagW:
        print("impossible")
    else:
        print("possible")
0