結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 210 ms
7,916 KB
testcase_01 AC 212 ms
7,868 KB
testcase_02 AC 213 ms
7,756 KB
testcase_03 AC 177 ms
7,856 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,928 KB
testcase_06 AC 16 ms
7,816 KB
testcase_07 AC 208 ms
7,868 KB
testcase_08 AC 16 ms
7,924 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 False if d['G'] != d['R'] or 0 in d.values() else True


N = int(input())

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