結果

問題 No.154 市バス
ユーザー roiti46roiti46
提出日時 2015-02-18 00:02:47
言語 Python2
(2.7.18)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 6,716 KB
実行使用メモリ 6,044 KB
最終ジャッジ日時 2023-08-03 09:04:17
合計ジャッジ時間 3,322 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 250 ms
6,044 KB
testcase_01 AC 250 ms
5,948 KB
testcase_02 AC 252 ms
5,924 KB
testcase_03 AC 184 ms
6,004 KB
testcase_04 AC 235 ms
5,852 KB
testcase_05 AC 12 ms
5,944 KB
testcase_06 AC 12 ms
5,944 KB
testcase_07 AC 250 ms
5,920 KB
testcase_08 AC 12 ms
5,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(raw_input())
for loop in xrange(T):
    S = raw_input()
    w = last = cnt = 0
    needG = False
    for s in S:
        if   s == "G":
            last += 1
            w -= 1
            needG = False
        elif s == "R":
            last -= 1
        else:
            w += 1
            needG = True
        if last < 0 or w < 0:
            print "impossible"
            break
    else:
        print "possible" if last == 0 and not needG else "impossible"
0