WA的一声哭了出来……

P4287 [SHOI2011] 双倍回文

WAMonster @ 2018-11-24 19:53:25

WA到只有76分。。。求助.。。是我思路错了吗qwq

CODE:

#include<cstdio>
#include<algorithm>
using namespace std;
#define maxn 1001000
char data[maxn];
int p[maxn];
int cnt,mid,r,ans;
int main()
{
    scanf("%*d"); 
    data[0]='$';
    char c=getchar();
    while(c<'a'||c>'z')c=getchar();
    while(c>='a'&&c<='z'){
        data[++cnt]='#';
        data[++cnt]=c;
        c=getchar();
    }
    data[++cnt]='#';
    for(int i=1;i<=cnt;++i){
        if(mid<i&&i<r)p[i]=min(p[(mid<<1)-i],r-i);
        while(data[i-p[i]]==data[i+p[i]])++p[i];
        if(i+p[i]>r){
            int lmid=(i*2-p[i]+1)>>1;
            if(data[i]=='#'&&data[lmid]=='#'&&lmid+p[lmid]-1==i)ans=max(ans,p[i]-1);
            r=i+p[i];
            mid=i;
        }
    }
    printf("%d",ans);
    return 0;
}

by 3493441984zz @ 2018-11-24 20:12:38

@超級·考場WA怪 大佬学马拉车啦


by WAMonster @ 2018-11-24 20:13:43

@野心qwq 这是真奇怪


by 3493441984zz @ 2018-11-24 20:14:23

@超級·考場WA怪 咋啦,我先看看题目哦,你等会


by 3493441984zz @ 2018-11-24 20:14:48

@超級·考場WA怪 你下午去机房了吗


by WAMonster @ 2018-11-24 20:20:00

@野心qwq 没啊


|