結果

問題 No.154 市バス
ユーザー phtmscgphtmscg
提出日時 2019-05-14 01:25:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 780 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 7,912 KB
最終ジャッジ日時 2023-09-22 23:29:09
合計ジャッジ時間 1,932 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 17 ms
7,852 KB
testcase_06 AC 15 ms
7,912 KB
testcase_07 AC 486 ms
7,764 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
for _ in range(N):
    C = input()[::-1]
    cr,cg,cw = C.count("R"),C.count("G"),C.count("W")
    if cr == cg and cw >= cr:
        Q = [0,0]
        while C:
            color = C[0]
            C = C[1:]
            if color == "R":
                Q[0] += 1
            elif color == "G" and Q[0]>Q[1]:
                Q[1] += 1
            elif color == "G":
                print("impossible")
                break
            elif Q[0]*Q[1]==0 and color == "W":
                print("impossible")
                break
            else:
                Q[0] -= 1
                Q[1] -= 1
        else:
            if Q[0] == 0:
                print("possible")
            else:
                print("impossible")
    else:
        print("impossible")
0