結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 14 ms
7,956 KB
testcase_06 AC 13 ms
7,804 KB
testcase_07 AC 198 ms
7,764 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

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:
        g-=1
        w+=1
    elif s=="G":
      if r==0:
        chk=False
      else:
        r-=1
        g+=1
    else:
      r+=1
  if r>0 or g>0:
    chk=False
  print("possible" if chk else "impossible")

0