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

Envío 2061

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

  • Autor: Javier
  • Fecha: 2020-11-20 23:23:57 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.007 s 1 KBi
#2
Correcto
0.007 s 1 KBi
#3
Correcto
0.007 s 1 KBi
#4
Correcto
0.007 s 1 KBi
#5
Correcto
0.008 s 1 KBi
#6
Correcto
0.007 s 1 KBi
#7
Tiempo límite excedido
1.029 s 2 KBi
#8
Tiempo límite excedido
1.073 s 2 KBi
#9
Tiempo límite excedido
1.015 s 1 KBi
#10
Tiempo límite excedido
1.006 s 2 KBi
#11
Tiempo límite excedido
1.005 s 1 KBi
#12
Tiempo límite excedido
1.082 s 2 KBi
#13
Tiempo límite excedido
1.015 s 1 KBi
#14
Tiempo límite excedido
1.018 s 1 KBi
#15
Tiempo límite excedido
1.013 s 2 KBi
#16
Tiempo límite excedido
1.073 s 2 KBi
#17
Tiempo límite excedido
0.929 s 1 KBi
#18
Tiempo límite excedido
1.059 s 2 KBi
#19
Tiempo límite excedido
1.074 s 1 KBi
#20
Tiempo límite excedido
1.004 s 1 KBi
#21
Tiempo límite excedido
1.017 s 1 KBi
#22
Tiempo límite excedido
0.915 s 1 KBi
Puntos totales: 28 / 100

Código

#include <iostream>
#include <string>

using namespace std;

int main() {
  string input;
  cin >> input;
  int max_border = 0;
  for (int i = 1; i < input.length(); i++) {
	 string left = input.substr(0, i);
	 int rightStart = input.length() - left.length();
	 string right = input.substr(rightStart);
	 if(left == right) {
		max_border = left.length();
	 }
  }
  cout << max_border << endl;
  return 0;
}