結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-02-20 03:29:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 559 ms / 2,000 ms |
| コード長 | 663 bytes |
| コンパイル時間 | 325 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 10,240 KB |
| 最終ジャッジ日時 | 2025-02-20 03:29:56 |
| 合計ジャッジ時間 | 3,817 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
from collections import Counter
def solve(s: str) -> bool:
t = Counter()
used_g = False
for c in reversed(s):
match c:
case 'W':
if not used_g: return False
if t['G'] > 0:
t['G'] -= 1
case 'G':
if t['R'] == 0: return False
used_g = True
t['R'] -= 1
t['G'] += 1
case 'R':
t['R'] += 1
if t['R'] or t['G']: return False
return True
T = int(input())
for _ in range(T):
S = input()
if solve(S):
print('possible')
else:
print('impossible')
norioc