結果

問題 No.154 市バス
ユーザー persimmon-persimmon
提出日時 2021-06-17 09:37:59
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 603 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 78,584 KB
最終ジャッジ日時 2025-01-02 11:53:48
合計ジャッジ時間 3,162 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 MLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

t=int(input())
sary=[input() for _ in range(t)]
from collections import Counter
for s in sary:
  cs=dict(Counter(s))
  if "W" not in cs or "G" not in cs or "R" not in cs:
    print("impossible")
    continue
  if cs["R"]!=cs["G"] or cs["R"]>cs["W"]:
    print("impossible")
    continue
  flg=True
  counter={"W":0,"G":0,"R":0}
  for x in s:
    counter[x]+=1
    if counter["W"]>=counter["G"]>=counter["R"]:
      pass
    else:
      flg=False
      break
    if counter["G"]==cs["G"] and x=="W":
      flg=False
      break
  if flg:
    print("possible")
  else:
    print("impossible")

        


0