rt,8 模哈希都给我卡掉了,蒟蒻玄关求调
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define ll long long
const int N=1e6+5;
const ll P[]={13331,1145141,131},M[]={123456791,19260817,1000000009};
int n,m;
ll Hs[3][3][N],Ht[3][3][N],pw[3][3][N];
std::string s,t;
__gnu_pbds::gp_hash_table<ll,bool>mp;
inline ll getval(const char c){
return c=='-'?13:c=='v'?19:c=='~'?23:29;
}
inline ll hashs(const int a,const int b,const int l,const int r){
return (Hs[a][b][r]-Hs[a][b][l-1]*pw[a][b][r-l+1]%M[b]+M[b])%M[b];
}
inline ll hasht(const int a,const int b,const int l,const int r){
return (Ht[a][b][r]-Ht[a][b][l-1]*pw[a][b][r-l+1]%M[b]+M[b])%M[b];
}
inline bool judge(const int a,const int b,const int len){
mp.clear();
for(int i=1;i+len-1<=n;++i){
mp[hashs(a,b,i,i+len-1)]=1;
}
for(int i=1;i+len-1<=m;++i){
if(mp[hasht(a,b,i,i+len-1)])return 1;
}
return 0;
}
inline bool check(const int len){
for(int i=0;i<=1;++i){
for(int j=0;j<=1;++j){
if(!judge(i,j,len))return 0;
}
}
if(!judge(0,1,len))return 0;
if(!judge(1,2,len))return 0;
if(!judge(0,2,len))return 0;
return 1;
}
signed main(){
std::cin.tie(0),std::cout.tie(0),std::ios::sync_with_stdio(0);
std::cin>>s>>t,n=s.size(),m=t.size(),s=' '+s,t=' '+t;
for(int a=0;a<=2;++a){
for(int b=0;b<=2;++b){
pw[a][b][0]=1;
for(int i=1,l=std::max(n,m);i<=l;++i){
pw[a][b][i]=pw[a][b][i-1]*P[a]%M[b];
}
}
}
for(int a=0;a<=2;++a){
for(int b=0;b<=2;++b){
for(int i=1;i<=n;++i){
Hs[a][b][i]=(Hs[a][b][i-1]*P[a]+getval(s[i]))%M[b];
}
for(int i=1;i<=m;++i){
Ht[a][b][i]=(Ht[a][b][i-1]*P[a]+getval(t[i]))%M[b];
}
}
}
int l=1,r=n,ans=0;
while(l<=r){
const int mid=(l+r)>>1;
if(check(mid))ans=mid,l=mid+1;
else r=mid-1;
}
std::cout<<ans;
return 0;
}