题解 | #密码截取#
密码截取
https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1
import sys for pom_line in sys.stdin: pom_line = pom_line.strip() odd, enev = [1] * len(pom_line), [0] * len(pom_line) for index, le in enumerate(pom_line): jv = 1 try: while pom_line[index - jv] == pom_line[index + jv]: odd[index] += 2 jv += 1 except: continue for index, le in enumerate(pom_line): jv = 1 try: if pom_line[index] == pom_line[index + 1]: enev[index] += 2 while pom_line[index - jv] == pom_line[index + 1 + jv]: enev[index] += 2 jv += 1 except: continue print(max(max(odd),max(enev)))