結果

問題 No.154 市バス
ユーザー pekempeypekempey
提出日時 2015-10-11 20:37:15
言語 PyPy2
(7.3.15)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 434 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 77,724 KB
実行使用メモリ 79,184 KB
最終ジャッジ日時 2023-08-03 10:54:48
合計ジャッジ時間 1,910 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(S):
	W = 0
	R = 0
	hasW = False
	hasR = False
	hasG = False
	for c in S:
		if c == 'W':
			W += 1
		elif c == 'G':
			W -= 1
		if W < 0: return False
	for c in S[::-1]:
		if c == 'W':
			if not hasG: return False
		elif c == 'G':
			hasG = True
			R -= 1
		else:
			R += 1
		if R < 0: return False
	return R == 0

T = input()
for i in xrange(T):
	S = raw_input()
	if check(S):
		print 'possible'
	else:
		print 'impossible'
0