結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:47:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 776 bytes |
| コンパイル時間 | 205 ms |
| コンパイル使用メモリ | 82,184 KB |
| 実行使用メモリ | 76,192 KB |
| 最終ジャッジ日時 | 2025-06-12 20:49:27 |
| 合計ジャッジ時間 | 1,548 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 2 MLE * 6 |
ソースコード
T = int(input())
for _ in range(T):
S = input().strip()
count_g = S.count('G')
count_r = S.count('R')
count_w = S.count('W')
if count_g != count_r:
print("impossible")
continue
if count_w < count_g:
print("impossible")
continue
current_g = 0
current_r = 0
w_so_far = 0
possible = True
for c in S:
if c == 'W':
w_so_far += 1
elif c == 'G':
current_g += 1
if w_so_far < current_g:
possible = False
break
elif c == 'R':
current_r += 1
if current_r > current_g:
possible = False
break
print("possible" if possible else "impossible")
gew1fw