結果

問題 No.154 市バス
ユーザー TsubajiroTsubajiro
提出日時 2022-05-20 23:43:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 11,912 KB
実行使用メモリ 11,312 KB
最終ジャッジ日時 2023-10-20 14:40:12
合計ジャッジ時間 3,223 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 277 ms
11,260 KB
testcase_01 AC 271 ms
11,260 KB
testcase_02 AC 273 ms
11,260 KB
testcase_03 AC 268 ms
11,256 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 26 ms
10,140 KB
testcase_07 AC 248 ms
11,240 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

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
    if not t[:-2]=="G" and t[:-1]=="R":
        Flag=False

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