QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#476819#801. 回文自动机Doqe#0 2ms9940kbC++14926b2024-07-13 21:04:512024-07-13 21:04:52

Judging History

你现在查看的是最新测评结果

  • [2024-07-13 21:04:52]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:9940kb
  • [2024-07-13 21:04:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace PAM
{
    const int N=1e6+10;
    char s[N];int n;
    int fa[N],tr[N][26],len[N],tt,up;
    int cnt[N];
    void ini()
    {
        tt=1;fa[1]=0,len[0]=-1;up=0;
    }
    int nxt(int x,int n)
    {
        while(s[n]!=s[n-len[x]-1])x=fa[x];
        return x;
    }
    void ins(int c)
    {
        int u=up;s[++n]=c;
        u=nxt(u,n);
        if(!tr[u][c-'a'])
        {
            tr[u][c-'a']=++tt;
            len[tt]=len[u]+2;
            fa[tt]=nxt(fa[u],n);
        }
        up=tr[u][c-'a'];
        ++cnt[up];
    }
}
char s[PAM::N];
int main()
{
    PAM::ini();int c;
    cin>>s+1;
    for(int i=1;s[i];++i)PAM::ins(s[i]);
    long long ans=0;
    for(int i=PAM::tt;i;--i)
    {
        PAM::cnt[PAM::fa[i]]+=PAM::cnt[i];
        ans=max(ans,1ll*PAM::len[i]*PAM::len[i]*PAM::cnt[i]);
    }
    cout<<ans<<endl;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 9940kb

input:

bdgedcfadbabbfgeacdgbggaefddebabbfgeacdgbefaecfddffeddacbabfcgecedacbffeddacbabfebadggfafabcdfdeaabdeecgbcecegcgecedacbfgdagbgagafdegecadfebcdbgfacdecdegecadfebbcdfdeaabdbfgcbccfcaebcecfdfccagdafaeaacbggaefddebcbecdafageeaabcbdafadcbecdbcgcbdgedcfadbcaefbdfcbgfcdeceddaaffgcedfcdcgdcgbfdddfdadgagbbef...

output:

4772

result:

wrong answer expected '5594', found '4772'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%