8538: Hacker

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

NIO is a hacker who likes to crack passwords for fun.


But one day he forgot his password. He quickly listed some vague clues. There is a lowercase string A of length n and k lowercase strings B1,…,Bk of length m. Given a uniform weight v1,…,vm represents the weight of each position of any Bi.

 
To figure out his password, for all Bi, he wants to find its maximum interval weight sum, and the string formed by this interval is a substring of A(An empty interval represents an empty string, which is legal).

输入格式

The first line contains three positive integers n,m,k(n,m,k≤105,m∗k≤106).
The second line contains a string A of length n.
The third line contains m integers vi(−109≤vi≤109).
The next k lines represent the string {Bi}.

输出格式

k lines for k answers.

输入样例 复制

10 8 5
aepeihmkkz
0 -3 2 -4 -5 2 -5 5
epesxnud
epeihmkk
peihmrgo
epeihqvy
eppjkuaz

输出样例 复制

2
5
2
2
5

数据范围与提示

For B1, the interval [3,3] forms the string 'e' is a substring of A and the interval sum is 2. Although the interval [1,3] forms the string 'epe' is also a substring of A, but the interval sum is -1 less than 2.

分类标签