結果

問題 No.672 最長AB列
ユーザー B9syDOfYhHFXecuB9syDOfYhHFXecu
提出日時 2018-10-31 10:13:42
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 717 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 7,040 KB
最終ジャッジ日時 2024-04-30 01:18:26
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

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