結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 312 ms
11,236 KB
testcase_01 AC 291 ms
11,236 KB
testcase_02 AC 309 ms
11,236 KB
testcase_03 AC 295 ms
11,232 KB
testcase_04 WA -
testcase_05 AC 30 ms
10,116 KB
testcase_06 AC 29 ms
10,116 KB
testcase_07 AC 266 ms
11,220 KB
testcase_08 AC 29 ms
10,116 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
    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