#pragma GCC optimize("Ofast") #include #include #include #include #include using namespace std; #define rep(i, n) for(int i=0;i= 0 && i+j < 2*n+1 && str[i-j] == str[i+j]) j++; rad[i] = j; int k = 1; while(i-k >= 0 && rad[i]-k > rad[i-k]) { rad[i+k] = rad[i-k]; ++k; } i += k; j = max(j-k,0); } } void construct_sa(string S){ int n = S.size(); rep(i, n){ sa[i] = i; } sort(sa, sa+n, [&](int a, int b){ return S[a] == S[b] ? a > b : S[a] < S[b]; }); for(int i=1;i= n || ran[sa[i]+k] != ran[sa[i+1]+k]); rep(i, n) ran[i] = tmp[i]; } //consider empty string for(int i=n;i>0;i--) sa[i] = sa[i-1]; sa[0] = n; rep(i,n+1) ran[sa[i]] = i; } void construct_lcp() { int h = 0; lcp[sa[0]] = 0; for(int i=0;iquery[1000005]; vectorin[1000005]; int main() { ios::sync_with_stdio(0); cin >> s1 >> s2; S = s1+"$"+s2; n = S.size(); construct_sa(S); construct_lcp(); manacher(); //odd cur = 0; init(); for(int i=0;i(m+1)/2;i--) { for(int j=0;j=1;i-=2) { for(int j=0;j s1.size()) add_b(in[i][j]); } for(int j=0;jm/2;i--) { for(int j=0;j=2;i-=2) { for(int j=0;j s1.size()) add_b(in[i][j]); } for(int j=0;j