結果

問題 No.154 市バス
ユーザー ntudantuda
提出日時 2024-01-05 00:19:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 447 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 1,075 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-01-05 00:19:25
合計ジャッジ時間 5,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 430 ms
9,984 KB
testcase_01 AC 438 ms
9,984 KB
testcase_02 AC 447 ms
9,984 KB
testcase_03 AC 320 ms
9,984 KB
testcase_04 AC 393 ms
9,984 KB
testcase_05 AC 27 ms
9,856 KB
testcase_06 AC 28 ms
9,856 KB
testcase_07 AC 415 ms
9,984 KB
testcase_08 AC 28 ms
9,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for j in range(int(input())):
    #print(j)
    W,R,G = 0,0,0
    lastw = 0
    lastg = 0
    S = input()
    for i,s in enumerate(S):
        if s == "W":
            W += 1
            lastw = i
        if s == "R":
            R += 1
        if s == "G":
            G += 1
            lastg = i
        if W < G or G < R:
            print("impossible")
            break

    else:
        if lastw > lastg:
            print("impossible")
            continue
        if R == G and R > 0:
            print("possible")
        else:
            print("impossible")
0