結果

問題 No.154 市バス
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-17 09:39:38
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 609 bytes
コンパイル時間 1,076 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 121,388 KB
最終ジャッジ日時 2023-08-30 18:03:25
合計ジャッジ時間 3,667 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

t=int(input())
sary=[list(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