#P8947. Angels & Demons
Angels & Demons
Background
The Pope’s chamberlain had already felt pain in his body. The pain quickly spread through his whole body, making him want to grab and scratch.
Do not forget the suffering Jesus endured.
He felt a burning pain in his throat, and even morphine could not relieve it.
What I had to do here is already done.
He had stirred awe in people’s hearts, and people had hope again.
When he was in the Pallium niche, the Pope’s chamberlain followed God’s teaching and performed the anointing ritual. His body, his hair and beard, his cheeks, his linen robe—everything was covered with lamp oil. At this moment, it was as if he were soaked in sacred green lamp oil, smelling sweet like a mother’s natural scent, yet highly flammable. He would be fortunate to ascend to Heaven. It would be a miraculous and swift process. What he would leave to the world would no longer be scandal... but a new power and a miracle.
His hand slipped into the pocket of his robe and took out the small golden lighter he had brought from the Pallium niche.
He softly spoke a sentence that God had said at the Last Judgment.
Blazing flames rush into the sky, and God’s angels will also ascend in the fire.
His thumb pressed down on the lighter.
People were still singing hymns in St. Peter’s Square...
Problem Description
Given template strings consisting of lowercase letters, and queries. The queries are of the following two types:
1 T: Given a query string consisting of lowercase letters.2 p l r: Let denote how many query strings have the substring as a substring. Compute .
Input Format
The first line contains three integers , where indicates the data type.
-
:
Lines to each contain one string. Line gives .
The next lines each contain one query, in the format described above.
-
:
The second line contains three integers .
The next lines each contain one string, representing a template string.
Then, the queries are generated by the following code (in the code,
lstdenotes the answer of the previous type query, initially ;le[i]denotes the length of template string ; andsis a char array):
while (q--) {
int op;
scanf("%d", &op);
if (op == 1) {
scanf("%s", s + 1);
int x((1ll * A * lst + B) % C), l(strlen(s + 1));
for (int i(1); i <= l; ++i) {
swap(s[i], s[x % l + 1]);
x = (1ll * A * x + B) % C;
}
} else {
int p, l, r;
scanf("%d%d%d", &p, &l, &r);
int x((1ll * A * lst + B) % C);
p = (p + x) % n + 1;
x = (1ll * A * x + B) % C;
l = (l + x) % le[p] + 1;
x = (1ll * A * x + B) % C;
r = (r + x) % le[p] + 1;
if (l > r) swap(l, r);
// update lst here
}
}
Output Format
For each type query, output one line containing one integer, the answer.
5 11 0
abb
aab
baab
bbaa
aabbb
1 ab
2 1 1 3
2 2 2 3
1 ba
2 3 1 2
2 4 1 2
2 4 2 3
1 abb
2 5 2 4
2 1 1 3
2 1 1 2
0
1
1
0
1
1
1
2
5 11 1
114 514 1919810
abb
aab
baab
bbaa
aabbb
1 ab
2 1 1 3
2 2 2 3
1 ba
2 3 1 2
2 4 1 2
2 4 2 3
1 abb
2 5 2 4
2 1 1 3
2 1 1 2
0
0
1
0
0
1
1
0
Hint
Constraints for of the testdata: , , , , , .
| Test Point | Score | Other Limits | |||||
|---|---|---|---|---|---|---|---|
| None. | |||||||
| Strings are random. | |||||||
| None. | |||||||
| Strings are random. | |||||||
| None. | |||||||
| Strings are random. | |||||||
| None. | |||||||
| Strings are random. | |||||||
| None. | |||||||
| Strings are random. | |||||||
| None. | |||||||
| Strings are random. | |||||||
| None. | |||||||
Test points to guarantee that for all type queries, .
Translated by ChatGPT 5