結果

問題 No.154 市バス
コンテスト
ユーザー pluto77
提出日時 2016-10-14 09:17:23
言語 Python2
(2.7.18)
結果
AC  
実行時間 353 ms / 2,000 ms
コード長 430 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 7,724 KB
最終ジャッジ日時 2025-12-03 22:01:35
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#yuki_154

n=int(raw_input())
for i in xrange(n):
 s=raw_input()[::-1]
 red=green=0
 pas=True
 res=False
 for c in s:
  if c=='R':
   red+=1
  if c=='G':
   if red<=0:
    pas=False
    break
   red-=1
   green+=1
  if c=='W':
   if green<=0 and res==False:
    pas=False
    break
   if green<1:
    green=0
   else:
    green-=1
   res=True
 if pas==True and red==0 and green==0:
  print "possible"
 else:
  print "impossible"
 
0