結果

問題 No.154 市バス
ユーザー mnrmnr
提出日時 2020-03-02 22:40:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 914 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 18,688 KB
最終ジャッジ日時 2024-04-21 22:54:09
合計ジャッジ時間 3,261 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 359 ms
18,560 KB
testcase_01 AC 359 ms
18,560 KB
testcase_02 AC 357 ms
18,560 KB
testcase_03 AC 303 ms
18,688 KB
testcase_04 WA -
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 313 ms
18,688 KB
testcase_08 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def judge(list):
    cnt_r = 0
    cnt_g = 0
    cnt_w = 0
    pori = False
    for i in range(1,len(list)+1):
        if list[-i] == 'R':
            cnt_r += 1
        elif list[-i] == 'G':
            cnt_g += 1
        elif list[-i] == 'W':
            cnt_w += 1
            
        if cnt_g > cnt_r:
            break
        elif cnt_g == 0 and cnt_w > 0:
            break
        elif cnt_r == 0 and cnt_w > 0:
            break

        if i == len(list):
            pori = True

    if list[0] == 'G' or list[0] == 'R' or list[1] == 'R':
        pori = False        
    if cnt_g != cnt_r:
        pori = False
    if cnt_w < cnt_g or cnt_w < cnt_r:
        pori = False
            
    if pori == True:
        print("possible")
    if pori == False:
        print("impossible")
    
T = int(input())
L = []
for i in range(T):
    S = input()
    L.append(list(S))
for i in range(T):
    judge(L[i])
0