結果

問題 No.154 市バス
ユーザー tabataba
提出日時 2016-04-16 23:55:07
言語 Python2
(2.7.18)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 7,068 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-04-21 09:24:32
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 242 ms
6,400 KB
testcase_01 AC 238 ms
6,400 KB
testcase_02 AC 236 ms
6,272 KB
testcase_03 AC 204 ms
6,400 KB
testcase_04 AC 238 ms
6,400 KB
testcase_05 AC 10 ms
6,400 KB
testcase_06 AC 10 ms
6,400 KB
testcase_07 AC 241 ms
6,272 KB
testcase_08 AC 10 ms
6,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in[0]*input():
	s=raw_input()
	g=r=p=0
	for c in s[::-1]:
		if c=="R":
			r+=1
		elif c=="G":
			g+=1
			if g>r:
				break
		elif c=="W":
			if r>0 and g==0 and p==0:
				break
			if g>0 and r>0:
				r-=1
				g-=1
				p+=1
		#print r,g
	if g==r and r==0 and s[-1]!="W":
		print"possible"
	else:
		print"impossible"
0