結果
| 問題 | No.154 市バス |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-05 10:35:46 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 158 ms / 2,000 ms |
| + 454µs | |
| コード長 | 700 bytes |
| 記録 | |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 7,040 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-07-18 09:10:23 |
| 合計ジャッジ時間 | 2,434 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
def solve(s):
numG, numR = s.count('G'), s.count('R')
if numG != numR or numG == 0:
return False
W, G, R = 0, 0, 0
Wassign = 0
for light in s:
if light == 'R':
R += 1
elif light == 'G':
G += 1
Wassign += 1
else:
W += 1
Wassign = max(Wassign-1, 0)
if (R == 0 or G == 0) and W > 0:
return False
if G > R:
return False
if Wassign > 0:
return False
if G == numG and R == numR and W >= numG:
return True
else:
return False
for t in xrange(input()):
print 'possible' if solve(raw_input()[::-1]) else 'impossible'