結果

問題 No.154 市バス
ユーザー TsubajiroTsubajiro
提出日時 2022-05-20 23:56:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 11,820 KB
実行使用メモリ 11,188 KB
最終ジャッジ日時 2023-10-20 14:52:48
合計ジャッジ時間 3,896 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 357 ms
11,188 KB
testcase_01 AC 354 ms
11,188 KB
testcase_02 AC 366 ms
11,188 KB
testcase_03 AC 350 ms
11,184 KB
testcase_04 AC 351 ms
11,188 KB
testcase_05 AC 29 ms
10,072 KB
testcase_06 AC 29 ms
10,072 KB
testcase_07 AC 327 ms
11,168 KB
testcase_08 AC 29 ms
10,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
tt=[]
for _ in range(T):
    tt.append(input())
for k,t in enumerate(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 or countW-countG<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