『Forensic Examination 后缀自动机 线段树合并』

情到浓时终转凉″ 提交于 2020-01-16 20:09:04


CF666E Forensic Examination

Description

给你一个串\(S\)以及一个字符串数组\(T[1..m]\)\(q\)次询问,每次问\(S\)的子串\(S[p_l..p_r]\)\(T[l..r]\)中的哪个串里的出现次数最多,并输出出现次数。

如有多解输出最靠前的那一个。

Input Format

The first line contains the string $ s $ ( $ 1<=|s|<=5·10^{5} $ ) — the Absolutely Inadmissible Swearword. The string $ s $ consists of only lowercase English letters.

The second line contains the only integer $ m $ ( $ 1<=m<=5·10^{4} $ ) — the number of texts of leaflets for expertise.

Each of the next $ m $ lines contains the only string $ t_{i} $ — the text of the $ i $ -th leaflet. The sum of lengths of all leaflet texts doesn't exceed $ 5·10^{4} $ . The text of the leaflets consists of only lowercase English letters.

The next line contains integer $ q $ ( $ 1<=q<=5·10^{5} $ ) — the number of queries for expertise.

Finally, each of the last $ q $ lines contains four integers $ l $ , $ r $ , $ p_{l} $ , $ p_{r} $ ( $ 1<=l<=r<=m,1<=p_{l}<=p_{r}<=|s| $ ), where $ |s| $ is the length of the Absolutely Inadmissible Swearword.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!