A10450 | Forensic Examination
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The country of Reberland is the archenemy of Berland. Recently the authorities of Berland arrested a Reberlandian spy who tried to bring the leaflets intended for agitational propaganda to Berland illegally . The most leaflets contain substrings of the Absolutely Inadmissible Swearword and maybe even the whole word.
Berland legal system uses the difficult algorithm in order to determine the guilt of the spy. The main part of this algorithm is the following procedure.
All the $m$ leaflets that are brought by the spy are numbered from $1$ to $m$ . After that it's needed to get the answer to $q$ queries of the following kind: "In which leaflet in the segment of numbers $[l,r]$ the substring of the Absolutely Inadmissible Swearword $[p_{l},p_{r}]$ occurs more often?".
The expert wants you to automate that procedure because this time texts of leaflets are too long. Help him!
Berland legal system uses the difficult algorithm in order to determine the guilt of the spy. The main part of this algorithm is the following procedure.
All the $m$ leaflets that are brought by the spy are numbered from $1$ to $m$ . After that it's needed to get the answer to $q$ queries of the following kind: "In which leaflet in the segment of numbers $[l,r]$ the substring of the Absolutely Inadmissible Swearword $[p_{l},p_{r}]$ occurs more often?".
The expert wants you to automate that procedure because this time texts of leaflets are too long. Help him!
输入格式
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.
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.
输出格式
Print $q$ lines. The $i$ -th of them should contain two integers — the number of the text with the most occurences and the number of occurences of the substring $[p_{l},p_{r}]$ of the string $s$ . If there are several text numbers print the smallest one.
输入输出样例
输入 #1
suffixtree 3 suffixtreesareawesome cartesiantreeisworsethansegmenttree nyeeheeheee 2 1 2 1 10 1 3 9 10
输出 #1
1 1 3 4
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted