結果

問題 No.154 市バス
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-19 02:44:08
言語 Python2
(2.7.18)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-04-21 08:12:18
合計ジャッジ時間 3,515 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 404 ms
6,272 KB
testcase_01 AC 407 ms
6,400 KB
testcase_02 AC 400 ms
6,272 KB
testcase_03 AC 327 ms
6,272 KB
testcase_04 AC 405 ms
6,272 KB
testcase_05 AC 10 ms
6,144 KB
testcase_06 AC 9 ms
6,272 KB
testcase_07 AC 313 ms
6,400 KB
testcase_08 AC 10 ms
6,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(raw_input())
for i in range(T):
    S=raw_input()
    Rcnt=0
    Gcnt=0
    ok=True
    oneBus =False
    for s in S[::-1]:
        if s=='R':
            Rcnt+=1
        if s=='G':
            if Rcnt <= 0:
                ok=False
                break
            Rcnt-=1
            Gcnt+=1
        if s=='W':
            if Gcnt <= 0 and oneBus==False:
                ok=False
                break
            Gcnt=max(0,Gcnt-1)
            oneBus = True
    if ok and Rcnt==0 and Gcnt==0:
        print 'possible'
    else:
        print 'impossible'
0