結果

問題 No.154 市バス
ユーザー pluto77pluto77
提出日時 2016-10-14 09:17:23
言語 Python2
(2.7.18)
結果
AC  
実行時間 301 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-04-21 09:57:53
合計ジャッジ時間 2,687 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
6,144 KB
testcase_01 AC 301 ms
6,272 KB
testcase_02 AC 298 ms
6,144 KB
testcase_03 AC 239 ms
6,272 KB
testcase_04 AC 289 ms
6,272 KB
testcase_05 AC 10 ms
6,144 KB
testcase_06 AC 9 ms
6,144 KB
testcase_07 AC 251 ms
6,272 KB
testcase_08 AC 10 ms
6,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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