結果
| 問題 | No.154 市バス |
| コンテスト | |
| ユーザー |
steek79
|
| 提出日時 | 2015-10-14 16:30:00 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 992 bytes |
| 記録 | |
| コンパイル時間 | 348 ms |
| コンパイル使用メモリ | 77,352 KB |
| 最終ジャッジ日時 | 2025-12-03 17:31:37 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 1 |
| other | MLE * 8 |
ソースコード
def check(str):
if str.count('W') >= str.count('R') == str.count('G') > 0:
cnt_w = cnt_g = cnt_r = 0
coming_green = False
coming_red = 0
for s in str:
if s == 'W':
coming_green = True
cnt_w += 1
elif s == 'G':
if coming_green > 0 and cnt_w > cnt_g:
coming_green = False
coming_red += 1
cnt_g += 1
else:
return 'impossible'
elif s == 'R':
if coming_red > 0 and cnt_g > cnt_r:
coming_red -= 1
cnt_r += 1
else:
return 'impossible'
else: return 'impossible'
#print coming_green, coming_red
if coming_green == coming_red == 0:
return 'possible'
else:
return 'impossible'
T = input()
for t in range(T):
print check(raw_input())
steek79