結果

問題 No.154 市バス
ユーザー syunsuke
提出日時 2018-10-07 11:07:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-12 14:09:46
合計ジャッジ時間 5,004 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 4 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

for i in range(N):
    S=input()
    ans=0
    cnt=0
    R=0
    G=0
    for j in range(len(S)):
        if S[j]=="G":
            ans+=1
            G+=1
        elif S[j]=="R":
            ans-=1
            R+=1
            if ans<0:
                print("impossible")
                R=0
                j=len(S)
        else:
            cnt+=1
        if len(S)==cnt+R+G:
            if ans==0:
                print("possible")
            else:
                print("impossible")
0