結果

問題 No.154 市バス
ユーザー Pump0129Pump0129
提出日時 2018-09-19 17:04:34
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 842 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 9,224 KB
最終ジャッジ日時 2023-09-25 10:11:44
合計ジャッジ時間 1,571 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
9,144 KB
testcase_01 AC 79 ms
9,168 KB
testcase_02 AC 80 ms
9,196 KB
testcase_03 AC 35 ms
9,100 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 73 ms
9,224 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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