結果

問題 No.154 市バス
ユーザー 👑 H20H20
提出日時 2022-02-13 02:26:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 815 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 17,016 KB
最終ジャッジ日時 2023-09-11 15:13:05
合計ジャッジ時間 6,712 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    S = list(input())
    S = S[::-1]
    USE = [0]*len(S)
    f = True
    if S[0]=='R':
        for i in range(len(S)):
            if not f:
                break
            if S[i]=='R':
                USE[i]=1
                for j in range(i,len(S)):
                    if S[j]=='G' and USE[j]==0:
                        USE[j]=1
                        for k in range(j,len(S)):
                            if S[k]=='W' and USE[k]==0:
                                USE[k]=1
                                break
                        else:
                            f = False
    else:
        f = False
    for i in range(len(S)):
        if USE[i]==0 and S[i]!='W':
            f=False 
    if f:
        print('possible')
    else:
        print('impossible')
0