Question link: Click the open link
Question:
Concatenates three strings.
Duplicate segments can be covered. The minimum length after question splicing (if a string s1 is a child string of s2, s1 can be considered to be embedded in s2 without splicing.
Ideas:
Kmp.
# Include
# Include
# Include
# Include
# Include
Using namespace std; # define N 300005 char T [N]; // starts from 0 to store int f [N]; // records P's self-matching void getFail (int len, char * P) {int I = 0, j =-1; f [0] =-1; while (I! = Len) {if (j =-1 | P [I] = P [j]) f [++ I] = ++ j; else j = f [j] ;}} int KMP (int * f2, char * S1, char * S2, int lens1, int lens2) {// f2 is the S2 mismatch array getFail (lens2, S2); int pos = 0, len = lens1, j = 0, I = 0; int gg = 0; while (I <= len) {while (j! =-1 & S1 [I]! = S2 [j]) j = f2 [j]; I ++, j ++; gg = max (j, gg); if (I = len) {pos = max (pos, j) ;}if (gg = lens2) return gg; return pos; // In this way, the maximum matching position (in S2) of the tail of S1 and the prefix of S2 is obtained}/**/char s [3] [N/3]; char tmp [N]; int l [3]; int hehe (int a, int B, int c) {int pos = KMP (f, s [a], s [B], l [a], l [B]); for (int I = 0; I <l [a]; I ++) tmp [I] = s [a] [I]; int top = l [a]; if (pos! = L [B]) for (; pos