結果

問題 No.154 市バス
ユーザー roiti46
提出日時 2015-02-17 23:31:02
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 392 bytes
コンパイル時間 64 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-10-13 06:20:18
合計ジャッジ時間 2,030 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(raw_input())
for loop in xrange(T):
    S = raw_input()
    w = last = 0
    for s in S:
        if   s == "G":
            last += 1
            w = 0
        elif s == "R":
            last -= 1
        else:
            if last > 0: w += 1
        if last < 0:
            print "Impossible"
            break
    else:
        print "Possible" if last == w == 0 else "Impossible"
0