結果

問題 No.672 最長AB列
ユーザー B9syDOfYhHFXecu
提出日時 2018-10-31 10:14:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 18,784 KB
最終ジャッジ日時 2024-11-19 11:53:05
合計ジャッジ時間 2,845 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
now_word = ''
change_index_list = []

for index, word in enumerate(s):
    if index == 0:
        now_word = word
    
    if word != now_word:
        change_index_list.append(index)
        now_word = word
        
change_index_list.append(len(s))
change_index_list.insert(0, 0)

max_len = 0
candidate_index = 0

for index, change_index in enumerate(change_index_list):
    if index == 0:
        continue
    
    elif index == len(change_index_list) - 1:
        break
    
    else:
        candidate_index = min([change_index - change_index_list[index-1], change_index_list[index+1] - change_index])
        
    if max_len < candidate_index:
        max_len = candidate_index
    
print(2*max_len)
0