結果

問題 No.154 市バス
ユーザー takakintakakin
提出日時 2020-05-01 18:15:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 405 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2023-08-26 00:39:20
合計ジャッジ時間 2,320 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 181 ms
7,804 KB
testcase_01 AC 189 ms
7,852 KB
testcase_02 AC 183 ms
7,812 KB
testcase_03 AC 182 ms
7,820 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,804 KB
testcase_06 AC 16 ms
7,960 KB
testcase_07 AC 196 ms
7,776 KB
testcase_08 AC 16 ms
7,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
t=int(input())
for _ in range(t):
  S=input()[::-1]
  w,g,r=0,0,0
  chk=True
  for s in S:
    if s=="W":
      if g==0:
        chk=False
      else:
        w+=1
    elif s=="G":
      if r==0:
        chk=False
      else:
        r-=1
        g+=1
    else:
      r+=1
  if r>0 or w<g:
    chk=False
  print("possible" if chk else "impossible")

0