█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 3471

Problema 0x43 - Encontrar el borde más largo de una string

  • Autor: jocarmp08
  • Fecha: 2021-03-15 06:18:20 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.031 s 3 KBi
#2
Correcto
0.032 s 3 KBi
#3
Correcto
0.028 s 3 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 23, in <module>
    print(string_edge(s))
  File "script.py", line 7, in string_edge
    right = s.find(s[left], right)
IndexError: string index out of range
0.019 s 3 KBi
#5
Correcto
0.031 s 3 KBi
#6
Correcto
0.03 s 3 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 23, in <module>
    print(string_edge(s))
  File "script.py", line 7, in string_edge
    right = s.find(s[left], right)
IndexError: string index out of range
0.077 s 3 KBi
#8
Correcto
0.085 s 3 KBi
#9
Correcto
0.146 s 8 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 23, in <module>
    print(string_edge(s))
  File "script.py", line 7, in string_edge
    right = s.find(s[left], right)
IndexError: string index out of range
0.086 s 3 KBi
#11
Incorrecto
0.086 s 3 KBi
#12
Correcto
0.08 s 3 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 23, in <module>
    print(string_edge(s))
  File "script.py", line 7, in string_edge
    right = s.find(s[left], right)
IndexError: string index out of range
0.091 s 3 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 23, in <module>
    print(string_edge(s))
  File "script.py", line 7, in string_edge
    right = s.find(s[left], right)
IndexError: string index out of range
0.095 s 3 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 23, in <module>
    print(string_edge(s))
  File "script.py", line 7, in string_edge
    right = s.find(s[left], right)
IndexError: string index out of range
0.078 s 3 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 23, in <module>
    print(string_edge(s))
  File "script.py", line 7, in string_edge
    right = s.find(s[left], right)
IndexError: string index out of range
0.1 s 3 KBi
#17
Correcto
0.04 s 3 KBi
#18
Incorrecto
0.034 s 3 KBi
#19
Incorrecto
0.082 s 3 KBi
#20
Incorrecto
0.036 s 3 KBi
#21
Incorrecto
0.024 s 3 KBi
#22
Correcto
0.023 s 3 KBi
Puntos totales: 46 / 100

Código

def string_edge(s):
    size = 0
    left = 0
    right = 1

    while True:
        right = s.find(s[left], right)

        if right == -1:
            break

        while left > 0 and s[left] != s[right]:
            left = 0

        if s[left] == s[right]:
            left += 1

        size = left

    return size

s = input()
print(string_edge(s))