結果
問題 | No.154 市バス |
ユーザー | Pump0129 |
提出日時 | 2018-09-19 17:14:39 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,287 bytes |
コンパイル時間 | 196 ms |
コンパイル使用メモリ | 10,900 KB |
実行使用メモリ | 9,372 KB |
最終ジャッジ日時 | 2023-09-25 10:12:26 |
合計ジャッジ時間 | 1,526 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 101 ms
9,324 KB |
testcase_01 | AC | 102 ms
9,368 KB |
testcase_02 | AC | 101 ms
9,372 KB |
testcase_03 | AC | 40 ms
9,208 KB |
testcase_04 | WA | - |
testcase_05 | AC | 16 ms
7,736 KB |
testcase_06 | AC | 16 ms
7,796 KB |
testcase_07 | AC | 85 ms
9,112 KB |
testcase_08 | AC | 16 ms
7,772 KB |
ソースコード
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" if t.count("G") == 0: return "impossible" if t.count("W") < t.count("G"): return "impossible" g_cnt = 0 r_cnt = 0 is_req_green = False is_req_red = False for c in t: if c == "G": g_cnt += 1 is_req_green = False elif c == "R": r_cnt += 1 is_req_red = False elif c == "W": is_req_green = True is_req_red = True if g_cnt < r_cnt: return "impossible" if is_req_red or is_req_green: return "impossible" return "possible" if __name__ == "__main__": que = No154() ans = que.solve() for s in ans: print(s)