結果

問題 No.154 市バス
ユーザー tikitaka1201tikitaka1201
提出日時 2020-09-16 21:34:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 334 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 7,884 KB
最終ジャッジ日時 2023-09-04 03:59:20
合計ジャッジ時間 3,258 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 322 ms
7,780 KB
testcase_01 AC 319 ms
7,884 KB
testcase_02 AC 330 ms
7,812 KB
testcase_03 AC 334 ms
7,844 KB
testcase_04 AC 327 ms
7,884 KB
testcase_05 AC 16 ms
7,776 KB
testcase_06 AC 16 ms
7,780 KB
testcase_07 AC 300 ms
7,820 KB
testcase_08 AC 16 ms
7,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t=int(input())
for _ in range(t):
    flg=True
    s=list(input())[::-1]
    n=len(s)
    wwgr=0
    wgr=0
    gr=0
    r=0
    for i in range(n):
        if s[i]=='R': 
            r+=1
        elif s[i]=='G':
            r-=1
            gr+=1
            if r<0:
                flg=False
        elif s[i]=='W':
            if gr>0:
                gr-=1
                wgr+=1
            elif wgr>0:
                wgr-=1
                wwgr+=1
            elif wwgr>0:
                pass
            else:
                flg=False
    if flg==False or r>0 or gr>0:
        print('impossible')
    else:
        print('possible')
0