結果

問題 No.672 最長AB列
コンテスト
ユーザー B9syDOfYhHFXecu
提出日時 2018-10-31 10:13:42
言語 PyPy2
(7.3.15)
結果
RE  
実行時間 -
コード長 717 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 203 ms
コンパイル使用メモリ 77,836 KB
最終ジャッジ日時 2025-12-04 01:25:48
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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