제출 #157327

#제출 시각아이디문제언어결과실행 시간메모리
157327likhon5회문 (APIO14_palindrome)C++14
0 / 100
200 ms131072 KiB
#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=300000;
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[node]++;
}
int   main()
{
    cin>>str;
    pre();
    for(ll i=0;i<str.size();i++) add(i);
    for(ll i=node;i>=3;i--)  cal[link[i]]+=cal[i];
    ll ans=-1;
    for(ll i=3;i<=node;i++)
    {
        ans=max(ans,len[i]*cal[i]);
    }
    cout<<ans<<endl;
}

컴파일 시 표준 에러 (stderr) 메시지

palindrome.cpp: In function 'int main()':
palindrome.cpp:41:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i=0;i<str.size();i++) add(i);
                ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...