#P7780. 「MCOI-Zero / AC6-M01」Invasion of Gracemeria
「MCOI-Zero / AC6-M01」Invasion of Gracemeria
Description
You are given a sequence of length , initially all , and a positive integer .
There are operations. Each operation gives , meaning to add to the suffix of the sequence .
After each operation, output the result of the sum of the -th powers of the occurrence counts of all values in the sequence, modulo .
is a prime number.
Input Format
The first line contains three integers .
The next lines each contain two integers, representing the operation .
Output Format
Output lines, each containing one integer: after this operation, the sum of the -th powers of the occurrence counts of all values in the sequence, modulo .
5 5 2
1 1
2 1
3 1
4 1
5 1
25
17
11
7
5
Hint
After the first operation, there are occurrences of , so the answer is .
After the second operation, there are occurrence of and occurrences of , so the answer is .
Similarly, the answers are , , and .
- Subtask 1 (20 pts): .
- Subtask 2 (40 pts): .
- Subtask 3 (40 pts): no special constraints.
For of the testdata, it is guaranteed that , , and .
idea: Sol1, solution: Sol1, code: Sol1, data: Sol1 & Xielan Canxiao (pinyin).
Translated by ChatGPT 5
京公网安备 11011102002149号