結果

問題 No.154 市バス
ユーザー syunsukesyunsuke
提出日時 2018-10-07 11:07:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-20 18:10:35
合計ジャッジ時間 4,805 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 520 ms
10,624 KB
testcase_01 AC 536 ms
10,752 KB
testcase_02 AC 511 ms
10,752 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 546 ms
10,752 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