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

Envío 2108

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

  • Autor: ppastram
  • Fecha: 2020-11-23 23:07:06 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#2
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#3
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#4
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#5
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#6
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#7
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#8
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#9
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#10
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#11
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#12
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#13
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#14
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#15
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#16
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#17
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#18
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#19
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#20
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#21
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
#22
Error de compilación
                      main.cpp:57:1: error: function definition is not allowed here
{
^
1 error generated.

                    
Puntos totales: 0 / 100

Código

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define rforn(a, n) for(int a = (n)-1; a>=0; --a)
using namespace std;
const int N = 6e5+20;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;

    if(s.size() == 0 || s.size() == 1) { cout<<0<<endl; return 0; }

    int lleva = 0;
    for(int i = 0, j = 1; j < s.size(); j++)
    {
        if(s[i] == s[j])
        {
            for(int k = i, l = j; k < s.size()-1 && l < s.size(); k++, l++)
            {
                if(s[k] != s[l]) {lleva = 0; break;}
                lleva++;
                //cout<<lleva<<endl;
            }
            //cout<<lleva<<endl;
            if(lleva != 0)
            {
                cout<<lleva<<endl;
      #include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define rforn(a, n) for(int a = (n)-1; a>=0; --a)
using namespace std;
const int N = 6e5+20;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;

    if(s.size() == 0 || s.size() == 1) { cout<<0<<endl; return 0; }

    int lleva = 0;
    for(int i = 0, j = 1; j < s.size(); j++)
    {
        if(s[i] == s[j])
        {
            for(int k = i, l = j; k < s.size()-1 && l < s.size(); k++, l++)
            {
                if(s[k] != s[l]) {lleva = 0; break;}
                lleva++;
                //cout<<lleva<<endl;
            }
            //cout<<lleva<<endl;
            if(lleva != 0)
            {
                cout<<lleva<<endl;
                return 0;
            }
        }
    }
    //if(lleva==s.size()) lleva++;
    cout<<lleva<<endl;
    return 0;
}          return 0;
            }
        }
    }
    //if(lleva==s.size()) lleva++;
    cout<<lleva<<endl;
    return 0;
}