結果

問題 No.154 市バス
コンテスト
ユーザー Pump0129
提出日時 2018-09-19 17:04:34
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 830 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 36,184 KB
最終ジャッジ日時 2026-04-02 00:10:32
合計ジャッジ時間 6,381 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 5 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

class No154:
    n = 0
    que_list = []

    def __init__(self):
        self.n = int(input())
        for i in range(self.n):
            self.que_list.append(input())

    def solve(self):
        ans_list = []
        for t in self.que_list:  # type: str
            ans_list.append(self.check_str(t))
        return ans_list

    @staticmethod
    def check_str(t):
        if not t.count("G") == t.count("R"):
            return "impossible"
        g_cnt = 0
        r_cnt = 0
        for c in t:
            if c == "G":
                g_cnt += 1
            elif c == "R":
                r_cnt += 1
            if g_cnt < r_cnt:
                return "impossible"
        return "possible"


if __name__ == "__main__":
    que = No154()
    ans = que.solve()
    for s in ans:
        print(s)
0