D. [Z-algorithm/KMP] String building time limit per test: 2…

Written by Anonymous on June 17, 2026 in Uncategorized with no comments.

Questions

D. [Z-аlgоrithm/KMP] String building time limit per test: 2 secоnds memоry limit per test: 256 megаbytes You wаnt to build a string s of size n that contains m instances of a pattern p starting at positions x1, x2, ..., xm. What is the number of possible values of s? Since the answer can be very large, print the answer modulo 109 + 7. Input The first line contains two integers n and m (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1) — the length of s and the number of starting positions for the pattern p. The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers x1, x2, ..., xm (1 ≤ x1 

Comments are closed.