結果

問題 No.154 市バス
ユーザー takakintakakin
提出日時 2020-05-01 18:24:01
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-08-26 00:51:38
合計ジャッジ時間 3,054 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 332 ms
7,768 KB
testcase_01 AC 320 ms
7,756 KB
testcase_02 AC 323 ms
7,764 KB
testcase_03 AC 306 ms
7,764 KB
testcase_04 AC 313 ms
7,844 KB
testcase_05 AC 14 ms
7,808 KB
testcase_06 AC 14 ms
7,816 KB
testcase_07 AC 253 ms
7,768 KB
testcase_08 AC 14 ms
7,940 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=min(w+1,g)
    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