結果

問題 No.154 市バス
ユーザー rlangevinrlangevin
提出日時 2023-03-05 23:23:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 483 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 10,168 KB
最終ジャッジ日時 2023-10-18 05:01:03
合計ジャッジ時間 3,720 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 483 ms
10,168 KB
testcase_01 AC 447 ms
10,168 KB
testcase_02 AC 444 ms
10,168 KB
testcase_03 AC 160 ms
10,168 KB
testcase_04 AC 461 ms
10,168 KB
testcase_05 AC 29 ms
10,132 KB
testcase_06 AC 30 ms
10,132 KB
testcase_07 AC 423 ms
10,168 KB
testcase_08 AC 29 ms
10,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    S = list(input())
    cntR = S.count("R")
    cntG = S.count("G")
    cntW = S.count("W")
    if cntR != cntG or cntR == 0 or cntW < cntG:
        print("impossible")
        continue
                
    flag = 1
    nR, nW, nG = 0, 0, 0
    for s in S:
        if s == "G":
            nG += 1
        elif s == "R":
            nR += 1
        else:
            nW += 1
        
        if nW < nG or nG < nR or (cntG == nG and cntW != nW) or (cntR == nR and cntW != nW):
            print("impossible")
            flag = 0
            break
    if flag == 0:
        continue
    print("possible")
0