結果

問題 No.154 市バス
ユーザー zakuro9715zakuro9715
提出日時 2016-06-19 23:15:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,504 KB
最終ジャッジ日時 2024-04-21 09:44:07
合計ジャッジ時間 10,745 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,156 ms
21,504 KB
testcase_01 AC 1,157 ms
10,624 KB
testcase_02 AC 1,191 ms
10,624 KB
testcase_03 WA -
testcase_04 AC 949 ms
10,752 KB
testcase_05 WA -
testcase_06 AC 26 ms
10,752 KB
testcase_07 TLE -
testcase_08 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def delete_before(s, c, n):
    for i in range(n - 1, -1, -1):
        if s[i] == c:
            s[i] = '#'
            return True
    return False

T = int(input())
for t in range(T):
    S = list(input())
    if S[-1] != 'R':
        print('impossible')
        continue
    for i, c in enumerate(S):
        if c == 'G':
            if not delete_before(S, 'W', i):
                print('impossible')
                break
        if c == 'R':
            if not delete_before(S, 'G', i):
                print('impossible')
                break
    else:
        print('possible')
0