CF547E.Mike and Friends

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

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

《父国》是一个奇特的国家!该国所有的电话号码都是由小写英文字母组成的字符串。更奇怪的是,一个电话号码可能对应多只熊!

该国有一支名为 CF 的摇滚乐队,由 nn 只熊(包括 Mike)组成,编号从 11 到 nn。

CF 的第 ii 位成员的电话号码为 sis_i。5 月 17 日是一个名为“电话呼叫日”的节日。在上一次“电话呼叫日”,每个人都拨打了自己电话号码的所有子串所对应的号码(一个人可能多次拨打同一号码)。特别地,每个人都给自己打了一次电话(这的确是个非常奇怪的国家)。

记 call(i, j)call(i, j) 为 CF 的第 ii 位成员拨打 CF 的第 jj 位成员的次数。

极客 Mike 向你提出了 qq 个问题。在每个问题中,他给出整数 ll、rr 和 kk,你需要告诉他以下表达式的值:

输入格式

The first line of input contains integers n and q (1 ≤ n ≤ 2 × 105 and 1 ≤ q ≤ 5 × 105).

The next n lines contain the phone numbers, i-th line contains a string s__i consisting of lowercase English letters ().

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).

输入的第一行包含两个整数 nn 和 qq(1≤n≤2×1051 \leq n \leq 2 \times 10^5,1≤q≤5×1051 \leq q \leq 5 \times 10^5)。

接下来的 nn 行包含电话号码,其中第 ii 行是一个字符串 sis_i,由小写英文字母组成()。

再接下来的 qq 行描述查询信息,每行包含三个整数 ll、rr 和 kk(1≤l≤r≤n1 \leq l \leq r \leq n,1≤k≤n1 \leq k \leq 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

输入解题思路,AI测评打分。不知道怎么写?

首页