Mike and Friends
题意翻译
给定 $n$ 个字符串 $s_{1 \dots n}$。
$q$ 次询问 $s_k$ 在 $s_{l \dots r}$ 中出现了多少次。
$n, \sum |s| \le 2 \times 10^5$,$q \le 5 \times 10^5$。
题目描述
What-The-Fatherland is a strange country! All phone numbers there are strings consisting of lowercase English letters. What is double strange that a phone number can be associated with several bears!
In that country there is a rock band called CF consisting of $ n $ bears (including Mike) numbered from $ 1 $ to $ n $ .
![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF547E/795f636f6e5e68bda106d7b6f30ea579c783740e.png)Phone number of $ i $ -th member of CF is $ s_{i} $ . May 17th is a holiday named Phone Calls day. In the last Phone Calls day, everyone called all the numbers that are substrings of his/her number (one may call some number several times). In particular, everyone called himself (that was really strange country).
Denote as $ call(i,j) $ the number of times that $ i $ -th member of CF called the $ j $ -th member of CF.
The geek Mike has $ q $ questions that he wants to ask you. In each question he gives you numbers $ l,r $ and $ k $ and you should tell him the number
![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF547E/a85d82cd6a7515cf5b34f6817bb4ac822d627734.png)
输入输出格式
输入格式
The first line of input contains integers $ n $ and $ q $ ( $ 1<=n<=2×10^{5} $ and $ 1<=q<=5×10^{5} $ ).
The next $ n $ lines contain the phone numbers, $ i $ -th line contains a string $ s_{i} $ consisting of lowercase English letters (![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF547E/98cedb4b676bf1b4f4302d3a962b63160a20ef91.png)).
The next $ q $ lines contain the information about the questions, each of them contains integers $ l,r $ and $ k $ ( $ 1<=l<=r<=n $ and $ 1<=k<=n $ ).
输出格式
Print the answer for each question in a separate line.
输入输出样例
输入样例 #1
5 5
a
ab
abab
ababab
b
1 5 1
3 5 1
1 5 2
1 5 3
1 4 5
输出样例 #1
7
5
6
3
6