hdu 3294 Girls' research

#include
#include
#define MAX 200020
char s[MAX],ss[MAX*2],str[2];
int  p[MAX*2];
int chance(char s)
{
  return (s- str[0] + 26) % 26 + 'a';     
}
int min(int a,int b){return a>b?b:a;}
int main()
{
  int i,id,mx,max,n,j,ans,m;
  
  while(scanf("%s%s",str,s)!=EOF)
  {
    ss[0]='$';
    n=strlen(s);
    for(i=0;ii)
      p[i]=min(p[2*id-i],mx-i);
      else
      p[i]=1;
      while(ss[i+p[i]]==ss[i-p[i]])
      {
        p[i]++;
      }
      if(i+p[i]>mx) 
      {
          mx=i+p[i];
          id=i;
      }
      if(p[i]>max)  {j=i;  max=p[i];}
      
    }
    if(max-1<2)
    printf("No solution!");
    else
    {
      if(j%2)
      ans=(j/2-(max-1)/2)+1;
      else
      ans=j/2-(max-1)/2;
      m=j/2+(max-1)/2;
      printf("%d %d\n",ans-1,m-1);
      for(i=ans-1;i

你可能感兴趣的:(HDU,poj,manacher,manacher)