結果

問題 No.154 市バス
ユーザー adothadoth
提出日時 2017-11-07 20:09:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 954 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-21 10:27:56
合計ジャッジ時間 1,759 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def main():
    n = int(input())

    for _ in range(n):
        memo = input()[::-1]
        W, G, R, pair_GR = 0, 0, 0, 0
        last_R, last_G, b = False, False, True

        for s in memo:
            if s == 'R':
                R += 1
                last_R = True

            elif s == 'G' and last_R:
                last_G = True
                if R > 0:
                    R -= 1
                    pair_GR += 1
                else:
                    print('impossible')
                    b = False
                    break

            elif s == 'W' and last_R and last_G:
                if pair_GR == 0:
                    print('impossible')
                    b = False
                    break
                elif pair_GR > 0:
                    W += 1

            else:
                print('impossible')
                b = False
                break

        if R == 0 and b:
            print('possible')

main()
0