結果

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

ソースコード

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
            if G == 0:
                W = 0
    return G == 0 and W == 0


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