結果

問題 No.672 最長AB列
ユーザー B9syDOfYhHFXecuB9syDOfYhHFXecu
提出日時 2018-10-31 10:14:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 19,040 KB
最終ジャッジ日時 2024-04-30 01:18:29
合計ジャッジ時間 2,956 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,624 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 33 ms
10,624 KB
testcase_04 AC 32 ms
10,624 KB
testcase_05 AC 30 ms
10,496 KB
testcase_06 AC 30 ms
10,496 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 66 ms
11,008 KB
testcase_10 AC 66 ms
11,008 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 186 ms
15,072 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

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