結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2021-02-09 20:56:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 144 ms / 2,000 ms |
コード長 | 730 bytes |
コンパイル時間 | 84 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-07 02:58:45 |
合計ジャッジ時間 | 1,933 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) def main(): S = input().rstrip()[::-1] R = 0 st = [] for s in S: if s == "R": R += 1 elif s == "G": if not R: return False R -= 1 st.append(1) else: if not st: return False st.append(0) if R: return False st.reverse() W = 0 for s in st: if s == 0: W += 1 else: if not W: return False W -= 1 return True T = int(input()) for _ in range(T): if main(): print("possible") else: print("impossible")