Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.01 s | 3 KBi |
#2 |
Correcto
|
0.011 s | 3 KBi |
#3 |
Correcto
|
0.011 s | 3 KBi |
#4 |
Correcto
|
0.01 s | 3 KBi |
#5 |
Correcto
|
0.014 s | 3 KBi |
#6 |
Correcto
|
0.015 s | 3 KBi |
#7 |
Correcto
|
0.065 s | 12 KBi |
#8 |
Correcto
|
0.074 s | 11 KBi |
#9 |
Correcto
|
0.064 s | 11 KBi |
#10 |
Correcto
|
0.071 s | 11 KBi |
#11 |
Correcto
|
0.061 s | 11 KBi |
#12 |
Correcto
|
0.096 s | 11 KBi |
#13 |
Correcto
|
0.079 s | 11 KBi |
#14 |
Correcto
|
0.098 s | 12 KBi |
#15 |
Correcto
|
0.068 s | 11 KBi |
#16 |
Correcto
|
0.068 s | 8 KBi |
#17 |
Correcto
|
0.06 s | 8 KBi |
#18 |
Incorrecto
|
0.082 s | 5 KBi |
#19 |
Incorrecto
|
0.059 s | 6 KBi |
#20 |
Incorrecto
|
0.08 s | 5 KBi |
#21 |
Correcto
|
0.077 s | 5 KBi |
#22 |
Correcto
|
0.055 s | 5 KBi |
from sys import stdin def prefix(p): m = len(p) pi = [0 for _ in range(m)] j = 0 for i in range(1, m): while j > 0 and p[i] != p[j]: j = pi[j - 1] if p[i] == p[j]: j += 1 pi[i] = j return pi def border(l2r, r2l): res = 0 for s, e in zip(l2r, reversed(r2l)): if s == e: res = max(res, s) return res for line in stdin: p = list(line[:-1]) l2r = prefix(p) p.reverse() r2l = prefix(p) r2l.reverse() print(border(l2r, r2l))