后缀数组,暴力硬跑
贼快1 #include2 #include 3 #include 4 #include 5 #include 6 #define MAXN 100005 7 using namespace std; 8 int buc[MAXN],wa[MAXN],wb[MAXN]; 9 int r[MAXN],sa[MAXN],rank[MAXN],height[MAXN];10 void getheight(int n){11 int i,j,k=0;12 for(i=0;i =j)y[p++]=sa[i]-j;28 for(i=0;i =a&&sa[pos]<=b)ans=max(ans,min(minn,min(b-sa[pos]+1,d-c+1)));52 minn=min(minn,height[pos]);53 for(int i=pos-1;i>=0;i--){54 if(minn<=ans)break;55 now=sa[i];56 if(now>=a&&now<=b)ans=max(ans,min(minn,min(b-sa[i]+1,d-c+1)));57 minn=min(minn,height[i]);58 }59 minn=min(d-c+1,b-a+1);60 for(int i=pos+1;i<=n;i++){61 minn=min(minn,height[i]);62 if(minn<=ans)break;63 now=sa[i];64 if(now>=a&&now<=b){ans=max(ans,min(minn,min(b-sa[i]+1,d-c+1)));}65 }66 printf("%d\n",ans);67 }68 return 0;69 }