hdu3294 Girls' research(manacher)

manacher模板吧。。就多了个翻译一下输出串。


#include 
#include 
#define N 200010
char op[1],str[N],s[N<<1];
int p[N<<1],n;
inline int min(int x,int y){return x=1&&i+p[i]<=n&&s[i-p[i]]==s[i+p[i]]) ++p[i];
			if(p[i]-1>ans) ans=p[i]-1,ansl=(i-p[i]+2)/2-1;
			if(i+p[i]>mx) mx=i+p[i],id=i;
		}
		if(ans<2) puts("No solution!");
		else{
			for(int i=1;i<=ans;++i) str[ansl+i]=(str[ansl+i]-op[0]+26)%26+'a';
			str[ansl+ans+1]=0;
			printf("%d %d\n%s\n",ansl,ansl+ans-1,str+ansl+1);
		}
	}
	return 0;
}


你可能感兴趣的:(其他oj,manacher)