Submission #7534341


Source Code Expand

Copy
#include<iostream>
using namespace std;
long long mas[5005];
void getZarr(string str)
{
    long long n = str.length();
    long long L, R, k;
    L = R = 0;
    for (long long i = 1; i < n; ++i)
    {
        if (i > R)
        {
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            mas[i] = R-L;
            R--;
        }
        else
        {
            k = i-L;
            if (mas[k] < R-i+1)
                mas[i] = mas[k];
            else
            {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                mas[i] = R-L;
                R--;
            }
        }
    }
}
bool srch(string concat,long long r)
{
    long long l = concat.length();
    getZarr(concat);
    for (long long i = 0; i < l; ++i)
    {
        if (mas[i] == r)
            return 1;
    }
    return 0;
}
int main()
{
    long long n,ans=0;
    string a,b;
    cin>>n>>a;
    for(long long i=0; i<n; i++){
        for(long long j=ans;; j++){
            if(j>=a.size()) break;
            b=a;
            b.insert(b.begin()+j+1,'#');
            if(srch(b,j+1)){
                ans++;
            }else{
                break;
            }
        }
        a.erase(a.begin());
    }
    cout<<ans;
}

Submission Info

Submission Time
Task E - Who Says a Pun?
User ansisg
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1367 Byte
Status AC
Exec Time 137 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 70
Set Name Test Cases
Sample 00-sample-00, 00-sample-01, 00-sample-02
All 00-sample-00, 00-sample-01, 00-sample-02, 01-handmade-03, 01-handmade-04, 01-handmade-05, 01-handmade-06, 01-handmade-07, 01-handmade-08, 01-handmade-09, 01-handmade-10, 01-handmade-11, 01-handmade-12, 02-binary-13, 02-binary-14, 02-binary-15, 02-binary-16, 02-binary-17, 02-binary-18, 02-binary-19, 02-binary-20, 02-binary-21, 02-binary-22, 02-binary-23, 03-BigRandom-24, 03-BigRandom-25, 03-BigRandom-26, 03-BigRandom-27, 03-BigRandom-28, 03-BigRandom-29, 03-BigRandom-30, 03-BigRandom-31, 03-BigRandom-32, 03-BigRandom-33, 03-BigRandom-34, 03-BigRandom-35, 03-BigRandom-36, 03-BigRandom-37, 03-BigRandom-38, 03-BigRandom-39, 03-BigRandom-40, 03-BigRandom-41, 03-BigRandom-42, 03-BigRandom-43, 03-BigRandom-44, 03-BigRandom-45, 03-BigRandom-46, 03-BigRandom-47, 03-BigRandom-48, 03-BigRandom-49, 03-BigRandom-50, 03-BigRandom-51, 03-BigRandom-52, 03-BigRandom-53, 03-BigRandom-54, 04-zero-55, 04-zero-56, 05-AllRandom-57, 05-AllRandom-58, 05-AllRandom-59, 05-AllRandom-60, 05-AllRandom-61, 05-AllRandom-62, 05-AllRandom-63, 05-AllRandom-64, 05-AllRandom-65, 05-AllRandom-66, 05-AllRandom-67, 05-AllRandom-68, 05-AllRandom-69
Case Name Status Exec Time Memory
00-sample-00 AC 1 ms 256 KB
00-sample-01 AC 1 ms 256 KB
00-sample-02 AC 1 ms 256 KB
01-handmade-03 AC 137 ms 256 KB
01-handmade-04 AC 134 ms 256 KB
01-handmade-05 AC 59 ms 256 KB
01-handmade-06 AC 59 ms 384 KB
01-handmade-07 AC 59 ms 384 KB
01-handmade-08 AC 120 ms 384 KB
01-handmade-09 AC 93 ms 384 KB
01-handmade-10 AC 102 ms 256 KB
01-handmade-11 AC 120 ms 256 KB
01-handmade-12 AC 136 ms 384 KB
02-binary-13 AC 69 ms 256 KB
02-binary-14 AC 81 ms 256 KB
02-binary-15 AC 63 ms 256 KB
02-binary-16 AC 93 ms 384 KB
02-binary-17 AC 93 ms 256 KB
02-binary-18 AC 80 ms 256 KB
02-binary-19 AC 50 ms 256 KB
02-binary-20 AC 60 ms 256 KB
02-binary-21 AC 55 ms 256 KB
02-binary-22 AC 53 ms 256 KB
02-binary-23 AC 46 ms 256 KB
03-BigRandom-24 AC 50 ms 256 KB
03-BigRandom-25 AC 50 ms 384 KB
03-BigRandom-26 AC 47 ms 256 KB
03-BigRandom-27 AC 55 ms 384 KB
03-BigRandom-28 AC 44 ms 256 KB
03-BigRandom-29 AC 52 ms 384 KB
03-BigRandom-30 AC 43 ms 256 KB
03-BigRandom-31 AC 50 ms 256 KB
03-BigRandom-32 AC 53 ms 256 KB
03-BigRandom-33 AC 42 ms 256 KB
03-BigRandom-34 AC 55 ms 384 KB
03-BigRandom-35 AC 41 ms 256 KB
03-BigRandom-36 AC 55 ms 256 KB
03-BigRandom-37 AC 53 ms 256 KB
03-BigRandom-38 AC 48 ms 384 KB
03-BigRandom-39 AC 56 ms 384 KB
03-BigRandom-40 AC 46 ms 384 KB
03-BigRandom-41 AC 54 ms 256 KB
03-BigRandom-42 AC 53 ms 256 KB
03-BigRandom-43 AC 50 ms 256 KB
03-BigRandom-44 AC 47 ms 256 KB
03-BigRandom-45 AC 51 ms 384 KB
03-BigRandom-46 AC 43 ms 256 KB
03-BigRandom-47 AC 53 ms 256 KB
03-BigRandom-48 AC 51 ms 384 KB
03-BigRandom-49 AC 49 ms 256 KB
03-BigRandom-50 AC 53 ms 384 KB
03-BigRandom-51 AC 55 ms 384 KB
03-BigRandom-52 AC 54 ms 256 KB
03-BigRandom-53 AC 54 ms 384 KB
03-BigRandom-54 AC 55 ms 384 KB
04-zero-55 AC 1 ms 256 KB
04-zero-56 AC 1 ms 256 KB
05-AllRandom-57 AC 38 ms 384 KB
05-AllRandom-58 AC 34 ms 384 KB
05-AllRandom-59 AC 38 ms 384 KB
05-AllRandom-60 AC 37 ms 256 KB
05-AllRandom-61 AC 36 ms 256 KB
05-AllRandom-62 AC 36 ms 256 KB
05-AllRandom-63 AC 34 ms 384 KB
05-AllRandom-64 AC 34 ms 384 KB
05-AllRandom-65 AC 35 ms 256 KB
05-AllRandom-66 AC 36 ms 384 KB
05-AllRandom-67 AC 35 ms 384 KB
05-AllRandom-68 AC 39 ms 384 KB
05-AllRandom-69 AC 39 ms 384 KB