結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 189 ms
7,836 KB
testcase_01 AC 176 ms
7,764 KB
testcase_02 AC 181 ms
7,868 KB
testcase_03 AC 180 ms
7,852 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,868 KB
testcase_06 AC 16 ms
7,864 KB
testcase_07 AC 199 ms
7,728 KB
testcase_08 AC 16 ms
7,724 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