Question:
Link: Best Reward
Question:
The essence of the question is to give you the character array v, string s, string by .... z, v [0] is the value of a, and so on, (must be divided) divides s into two strings, if the value of a text return is the sum of v [I], the value is 0 instead of a text return. Find the maximum value.
Algorithm:
EKMP algorithm. EMP algorithm details: Click to open the link
Ideas:
...........
Code:
# Include
# Include
# Include
Using namespace std; char s1 [500010], s2 [500010]; int sum [500010], next [500010]; int v [30]; int extend1 [500010], extend2 [500010]; void EKMP (char s [], char t [], int next [], int extend []) // evaluate the template of the extend Array {int I, j, p, l; int len = strlen (t); int len1 = strlen (s); memset (next, 0, sizeof (next); memset (extend, 0, sizeof (extend); next [0] = len; j = 0; while (1 + j
> T; while (t --) {for (int I = 0; I <26; I ++) cin> v [I]; getchar (); gets (s1); int len = strlen (s1); sum [0] = 0; for (int I = 0; I
> 30; for (int I = 1; I
Ans) ans = temp;} cout <