結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2018-09-19 17:14:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,287 bytes |
コンパイル時間 | 73 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-07-18 08:17:57 |
合計ジャッジ時間 | 1,306 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 1 |
ソースコード
class No154:n = 0que_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: strans_list.append(self.check_str(t))return ans_list@staticmethoddef 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 = 0r_cnt = 0is_req_green = Falseis_req_red = Falsefor c in t:if c == "G":g_cnt += 1is_req_green = Falseelif c == "R":r_cnt += 1is_req_red = Falseelif c == "W":is_req_green = Trueis_req_red = Trueif 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)