結果

問題 No.154 市バス
ユーザー Mr.FukuMr.Fuku
提出日時 2018-08-05 15:08:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 396 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 10,184 KB
最終ジャッジ日時 2023-10-19 22:05:20
合計ジャッジ時間 1,592 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
10,184 KB
testcase_01 AC 109 ms
10,184 KB
testcase_02 AC 109 ms
10,184 KB
testcase_03 AC 97 ms
10,184 KB
testcase_04 AC 110 ms
10,184 KB
testcase_05 AC 30 ms
10,164 KB
testcase_06 AC 29 ms
10,164 KB
testcase_07 AC 102 ms
10,184 KB
testcase_08 AC 30 ms
10,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(S):
    w,g,r=0,0,0
    for s in S[::-1]:
        if s=='R':
            r+=1
        elif s=='G':
            g+=1
            if g>r:
                return False
        elif g==0:
            return False
        elif w<g:
            w+=1
    return w==g==r

n = int(input())
for i in range(n):
    if solve(input()):
        print("possible")
    else:
        print("impossible")
0