Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.026 s | 3 KBi |
#2 |
Correcto
|
0.024 s | 3 KBi |
#3 |
Correcto
|
0.023 s | 3 KBi |
#4 |
Correcto
|
0.022 s | 3 KBi |
#5 |
Correcto
|
0.022 s | 3 KBi |
#6 |
Correcto
|
0.022 s | 3 KBi |
#7 |
Correcto
|
0.054 s | 7 KBi |
#8 |
Correcto
|
0.057 s | 7 KBi |
#9 |
Correcto
|
0.068 s | 7 KBi |
#10 |
Correcto
|
0.055 s | 7 KBi |
#11 |
Correcto
|
0.044 s | 7 KBi |
#12 |
Correcto
|
0.058 s | 7 KBi |
#13 |
Correcto
|
0.07 s | 7 KBi |
#14 |
Correcto
|
0.059 s | 7 KBi |
#15 |
Correcto
|
0.075 s | 7 KBi |
#16 |
Correcto
|
0.072 s | 7 KBi |
#17 |
Correcto
|
0.055 s | 5 KBi |
#18 |
Correcto
|
0.058 s | 4 KBi |
#19 |
Correcto
|
0.064 s | 4 KBi |
#20 |
Correcto
|
0.051 s | 4 KBi |
#21 |
Correcto
|
0.067 s | 4 KBi |
#22 |
Correcto
|
0.048 s | 4 KBi |
# Knuth-Morris-Pratt Algorithm def get_longest_border(string): length = len(string) border_length_prefix = [0] * length j = 0 for i in range(1, length): while j >= 0 and string[j] != string[i]: if j - 1 >= 0: j = border_length_prefix[j - 1] else: j = -1 j += 1 border_length_prefix[i] = j return border_length_prefix print(get_longest_border(input())[-1])