結果

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

ソースコード

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
    t.reverse()
    countG2=0
    for i in t:
        if i=="G":
            break
        if i=="W":
            if countG2==0:
                Flag=False
                break
    #print(Flag,FlagW)

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