結果

問題 No.154 市バス
ユーザー TsubajiroTsubajiro
提出日時 2022-05-20 23:36:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 863 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 11,272 KB
最終ジャッジ日時 2023-10-20 14:32:29
合計ジャッジ時間 4,893 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 28 ms
10,096 KB
testcase_06 AC 28 ms
10,096 KB
testcase_07 AC 471 ms
11,200 KB
testcase_08 AC 28 ms
10,096 KB
権限があれば一括ダウンロードができます

ソースコード

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