結果

問題 No.154 市バス
ユーザー mnr
提出日時 2020-03-02 23:05:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 934 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 18,688 KB
最終ジャッジ日時 2024-10-13 21:21:23
合計ジャッジ時間 2,842 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other AC * 7 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def judge(list):
    cnt_r = 0
    cnt_g = 0
    cnt_w = 0
    pori = True
    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:
            pori = False
            break
        elif cnt_g == 0 and cnt_w > 0:
            pori = False
            break
        elif cnt_r == 0 and cnt_w > 0:
            pori = False
            break

    if cnt_g != cnt_r:
        pori = False
    elif cnt_w < cnt_g or cnt_w < cnt_r:
        pori = False
    elif list[0] == 'G' or list[0] == 'R' or list[1] == 'R':
        pori = False
            
    if pori == True:
        print("possible")
    elif 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