結果

問題 No.154 市バス
ユーザー daleksprinterdaleksprinter
提出日時 2018-08-19 17:29:53
言語 Python2
(2.7.18)
結果
AC  
実行時間 411 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 20:31:12
合計ジャッジ時間 3,980 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 366 ms
6,816 KB
testcase_01 AC 365 ms
6,940 KB
testcase_02 AC 364 ms
6,944 KB
testcase_03 AC 367 ms
6,944 KB
testcase_04 AC 365 ms
6,940 KB
testcase_05 AC 11 ms
6,944 KB
testcase_06 AC 11 ms
6,940 KB
testcase_07 AC 411 ms
6,940 KB
testcase_08 AC 11 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

for i in range(n):

	syscnt = 0
	stk = []

	s = raw_input()

	possible = True
	chkind = 0
	wcount = 0
	for j in range(len(s)):
		
		if s[j] == 'W':
			wcount += 1

		if s[j] == 'G':
			stk.append('g')
			syscnt += 1
			if wcount < syscnt:
				possible = False 
			chkind = j
			
		elif s[j] == 'R':
			if not stk :
				possible = False
			else :
				stk.pop()
			
	if stk :
		possible = False

	for i in range(chkind,len(s)):
		if s[i] == 'W':
			possible = False

	print 'possible' if possible else 'impossible'

0