pref function
Problem
Given a string S
. Find the sum of the values of the prefix function for all given positions of the string S
.
Input
The first line of the input file contains the string S
(\(1 <= |S| <= 150 000\)) and k
(number of specified positions).
Followed by k
numbers - positions, the values of the prefix function of which must be added.
Output
Output a single number in the output file - the sum of the values of the prefix function for all specified positions of the string S
.
Examples
# |
Input |
Output |
1 |
abacaba 2
3
7
|
4 |