結果

問題 No.154 市バス
ユーザー ebicochinealebicochineal
提出日時 2016-06-20 17:57:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-21 09:46:51
合計ジャッジ時間 3,108 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 342 ms
10,624 KB
testcase_01 AC 343 ms
10,752 KB
testcase_02 AC 321 ms
10,752 KB
testcase_03 AC 262 ms
10,624 KB
testcase_04 AC 301 ms
10,624 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 28 ms
10,624 KB
testcase_07 AC 347 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for i in range(int(input())):
    s = input()
    w, g, r, l = 0, 0, 0, s.count("G")
    f = 1 if s[0] != "W" else 0
    for j in s:
        if j == "W":
            w += 1
            if l == 0:
                f = 1
        if j == "G":
            if l > 0 and w > 0:
                w -= 1; l -= 1; g += 1
            else:
                f = 1
        if j == "R":
            if g > 0:
                g -= 1; r += 1
            else:
                f = 1
        if f : break
    print("possible" if f == 0 and g == 0 else "impossible")
0