結果

問題 No.154 市バス
ユーザー H3PO4H3PO4
提出日時 2020-05-06 23:50:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 10,692 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-09-16 07:37:41
合計ジャッジ時間 2,419 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 211 ms
7,760 KB
testcase_01 AC 215 ms
7,820 KB
testcase_02 AC 215 ms
7,972 KB
testcase_03 AC 178 ms
7,764 KB
testcase_04 WA -
testcase_05 AC 15 ms
7,944 KB
testcase_06 AC 15 ms
7,792 KB
testcase_07 AC 204 ms
7,776 KB
testcase_08 AC 15 ms
7,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(S):
    d = {'W': 0, 'G': 0, 'R': 0}
    for s in reversed(S):
        if s == 'G' and d['R'] == 0:
            return False
        elif s == 'W' and d['G'] == 0:
            return False
        d[s] += 1
        if d['G'] > d['R']:
            return False
    return True if d['W'] >= d['G'] == d['R'] and 0 not in d.values() else False


N = int(input())

for _ in range(N):
    print('possible' if solve(input()) else 'impossible')
0