Codeforces Round # 579 (Div. 3) D (string, thinking)

#include <bits / STDC ++ H.>
the using namespace STD;
char S [200007], T [200007];
int Last [200007] [27], NXT [200007] [27];
int L [200007], R & lt [200007 ];
int main () {
CIN >> >> S + T +. 1. 1;
int n-= strlen (S +. 1);
int m = strlen (T +. 1);
for (int I =. 1; I <= n- ; I ++) {
for (int J = 0; J <26 is; J ++)
Last [I] [J] = Last [. 1-I] [J]; // I represents the current position, j represents letter size , copies the current position at the latest before the advent of the letter j is the position of the previous frame j letters occurs last position before
last [i] [s [i ] - 'a'] = i; // update the current position at the latest before position of the letter appears s [i] is
}
{- for (int I = n-I;; I)
for (int J ++ J = 0;; J <26 is)
= NXT NXT [I] [J] [I + . 1] [j]; j is the position of the letters after the earliest // copy the current position of the letter j is a position before the earliest previous cell location
[i nxt] [s [i ] - 'a'] = i; // update after the location of the current position of the earliest letters s [i] in
}
int = now. 1;
L [0] =. 1;
for (int I =. 1; I <= m; I ++) {
now = nxt [now] [t [i] - 'a'] + 1; letter position t [i] // now represents the earliest after the position now, still have to ensure that the position after the remaining string t i + ~ m. 1
L [i] = now; i // update the left end point is now
}
now n-=;
R & lt [m +. 1] = n-;
for (int i = m; i; - i) {
now = last [now] [t [ i] - 'a'] - 1; // now now represents the letter position t [i] at the latest before the advent of, ensure that the position of the string still have remaining before t 1 . 1-i
R & lt [i] = now; i // update the position of the right end point is now
}
int ANS = 0;
for (int i = 0; i <= m; i ++)
ANS = max (R & lt [i +1] -l [i] + 1 , ans); // update answer the letter t [i + 1 positions] minus occurs last letter t [i] + 1 position earliest
COUT << ANS;
return 0;
}

Guess you like

Origin www.cnblogs.com/ldudxy/p/11351526.html
Recommended