結果

問題 No.154 市バス
ユーザー tktk_snsn
提出日時 2021-02-09 20:29:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-07 02:34:41
合計ジャッジ時間 1,515 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    S = input().rstrip()
    W = 0
    G = 0
    for s in S:
        if s == "W":
            W += 1
        elif s == "G":
            if not W:
                return False
            W -= 1
            G += 1
        else:
            if not G:
                return False
            G -= 1
    return G == 0


T = int(input())
for _ in range(T):
    if main():
        print("possible")
    else:
        print("impossible")
0