Submission #157334

# Submission time Handle Problem Language Result Execution time Memory
157334 2019-10-10T19:11:03 Z likhon5 Palindromes (APIO14_palindrome) C++14
100 / 100
120 ms 69160 KB
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=1000009;
ll nxt[mx][26];
ll len[mx],link[mx];
ll node,t;
string str;
void pre()
{
    len[1]=-1,len[2]=0;
    link[1]=link[2]=1;
    node=t=2;
}
ll cal[mx];
void add(ll p)
{
    while(str[p-len[t]-1]!=str[p]) t=link[t];
    ll x=link[t];
    while(str[p-len[x]-1]!=str[p]) x=link[x];
    ll c=str[p]-'a';
    if(nxt[t][c]==false)
    {
        nxt[t][c]=++node;
        len[node]=len[t]+2;
        link[node]=(len[node]==1)? 2: nxt[x][c];
    }
    t=nxt[t][c] ;
    cal[t]++;
}
int   main()
{
    cin>>str;
    pre();
    int n=str.size();
    for(ll i=0;i<n;i++) add(i);
    for(ll i=node;i>=3;i--)  cal[link[i]]+=cal[i];
    ll ans=0;
    for(ll i=3;i<=node;i++)
    {
        ans=max(ans,len[i]*cal[i]);
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 412 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 5 ms 2680 KB Output is correct
4 Correct 5 ms 2656 KB Output is correct
5 Correct 6 ms 2680 KB Output is correct
6 Correct 5 ms 2680 KB Output is correct
7 Correct 5 ms 2680 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 5 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 23232 KB Output is correct
2 Correct 35 ms 23304 KB Output is correct
3 Correct 36 ms 23220 KB Output is correct
4 Correct 36 ms 23288 KB Output is correct
5 Correct 40 ms 23272 KB Output is correct
6 Correct 34 ms 17144 KB Output is correct
7 Correct 32 ms 19832 KB Output is correct
8 Correct 10 ms 888 KB Output is correct
9 Correct 16 ms 5880 KB Output is correct
10 Correct 36 ms 19960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 68856 KB Output is correct
2 Correct 101 ms 68880 KB Output is correct
3 Correct 102 ms 69160 KB Output is correct
4 Correct 102 ms 69140 KB Output is correct
5 Correct 120 ms 69136 KB Output is correct
6 Correct 103 ms 61588 KB Output is correct
7 Correct 93 ms 57656 KB Output is correct
8 Correct 25 ms 1300 KB Output is correct
9 Correct 25 ms 1296 KB Output is correct
10 Correct 110 ms 56724 KB Output is correct
11 Correct 100 ms 69112 KB Output is correct
12 Correct 32 ms 7696 KB Output is correct