結果

問題 No.154 市バス
コンテスト
ユーザー cologne
提出日時 2025-12-11 13:02:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 619 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 286 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2025-12-11 13:02:50
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys


def input(): return sys.stdin.readline().rstrip('\n')


def main():
    def solve(x):
        r = g = 0
        for c in x:
            if c == 'R':
                r += 1
            elif c == 'G':
                if r == 0:
                    return False
                else:
                    r -= 1
                    g += 1
            else:
                g = max(0, g - 1)
        return r == g == 0

    for _ in range(int(input())):
        print('possible' if solve(input()[::-1]) else 'impossible')


if __name__ == '__main__':
    ret = main()
    if ret is not None:
        print(ret)
0