結果

問題 No.154 市バス
ユーザー pluto77pluto77
提出日時 2016-03-15 08:07:56
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:19:13
合計ジャッジ時間 3,485 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 381 ms
6,272 KB
testcase_01 AC 384 ms
6,144 KB
testcase_02 AC 386 ms
6,016 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 11 ms
6,272 KB
testcase_06 AC 11 ms
6,144 KB
testcase_07 AC 354 ms
6,272 KB
testcase_08 AC 10 ms
6,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
#yuki_154

t=int(raw_input())
for i in xrange(t):
 s=raw_input()
 rgcount=0
 rflag=False
 gflag=False
 if s[0]=='G' or s[0]=='R':
  print "impossible"
  continue
 pi=True
 for j in xrange(len(s)-1,-1,-1):
  st=s[j]
  if st=='R':
   rgcount+=1
   rflag=True
  elif st=='G':
   rgcount-=1
   gflag=True
  elif st=='W':
   if rflag==False or gflag==False:
    pi=False
    break
  if rgcount<0:
   pi=False
 if pi==True:
  print "possible"
 else:
  print "impossible"
0