結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2023-01-21 17:46:19 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 893 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,600 KB |
実行使用メモリ | 78,056 KB |
最終ジャッジ日時 | 2024-06-24 00:53:34 |
合計ジャッジ時間 | 2,617 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 1 WA * 1 MLE * 6 |
ソースコード
def answer():S = list(input())W = [int(i == 'W') for i in S]G = [int(i == 'G') for i in S]R = [int(i == 'R') for i in S]N = len(S)from itertools import accumulateSW = list(accumulate(W))SG = list(accumulate(G))SR = list(accumulate(R))for i in range(N):if SW[i]>=SG[i]>=SR[i]:continueelse:print('impossible')returnif SG[-1] != SR[-1]:print('impossible')returnLG = NLR = Nfor i in range(N-1,-1,-1):if S[i]=='R':LR = ibreakfor i in range(N-1,-1,-1):if S[i]=='G':LG = ibreakif LR<LG:print('impossible')returnif LR!=N-1:print('impossible')returnprint('possible')returnfor _ in range(int(input())):answer()