結果

問題 No.154 市バス
ユーザー syunsukesyunsuke
提出日時 2018-10-07 11:07:14
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 10,664 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-08-02 18:00:39
合計ジャッジ時間 4,611 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 476 ms
7,920 KB
testcase_01 AC 496 ms
7,924 KB
testcase_02 AC 485 ms
7,892 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 493 ms
7,888 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

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