QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#12930. 钟赫与字符串

Estadísticas

Jong Hyok 热爱由小写英文字母组成的字符串。有一天,他给他的朋友出了一个问题,而这个人正好是你!他在你面前写下了 $n$ 个字符串 $P_1, P_2, \dots, P_n$,然后提出了 $m$ 个问题。

考虑一个字符串 $S$。定义 $StrangeSet(S)$ 为所有满足 $S$ 在 $P_i$ 中作为子串且结束位置为 $j$ 的二元组 $(i, j)$ 的集合。

当询问第 $k$ 个问题时,Jong Hyok 会给你一个字符串 $Q_k$。你需要找出满足 $StrangeSet(Q_k) = StrangeSet(T)$ 且 $T$ 是给定 $n$ 个字符串中至少一个字符串的子串的不同字符串 $T$ 的数量。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 10^5, 1 \le m \le 5 \cdot 10^5$)。

接下来的 $n$ 行包含字符串 $P_1, P_2, \dots, P_n$,每行一个 ($1 \le |P_i| \le 10^5$)。

随后的 $m$ 行包含字符串 $Q_1, Q_2, \dots, Q_m$,每行一个 ($1 \le |Q_k| \le 10^5$)。

所有 $n+m$ 个字符串均由小写英文字母组成。

输入中所有 $|P_i|$ 的总和不超过 $10^5$。

输入中所有 $|P_i|$ 和所有 $|Q_k|$ 的总和最多为 $2 \cdot 10^6$。

输出格式

对于每个问题,在单独的一行中输出一个整数:该问题的答案。

样例

输入 1

2 2
aba
ab
a
ab

输出 1

1
2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.