結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:39:30 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,053 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 82,380 KB |
実行使用メモリ | 77,032 KB |
最終ジャッジ日時 | 2025-03-31 17:40:32 |
合計ジャッジ時間 | 1,830 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 1 WA * 1 MLE * 6 |
ソースコード
T = int(input()) for _ in range(T): s = input().strip() if not s: print("impossible") continue # Check if the last character is R if s[-1] != 'R': print("impossible") continue # Check if the counts of G and R are equal count_g = s.count('G') count_r = s.count('R') if count_g != count_r: print("impossible") continue # Check that R counts never exceed G counts at any position current_g = 0 current_r = 0 possible = True for c in s: if c == 'G': current_g += 1 elif c == 'R': current_r += 1 if current_r > current_g: possible = False break if not possible: print("impossible") continue # Check that each G has at least one W before it g_positions = [i for i, char in enumerate(s) if char == 'G'] for pos in g_positions: if 'W' not in s[:pos]: possible = False break print("possible" if possible else "impossible")