結果

問題 No.154 市バス
ユーザー pluto77pluto77
提出日時 2016-03-14 21:12:47
言語 PyPy2
(7.3.15)
結果
MLE  
実行時間 -
コード長 513 bytes
コンパイル時間 1,373 ms
コンパイル使用メモリ 76,928 KB
実行使用メモリ 78,720 KB
最終ジャッジ日時 2024-04-21 09:18:57
合計ジャッジ時間 3,344 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 #

# coding: utf-8
#yuki_154

t=int(raw_input())
for i in xrange(t):
 s=raw_input()
 rgcount=0
 rflag=False
 gflag=False
 if len(s)==1:
  print "impossible"
  continue
 if s=="GR":
  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