#P7780. 「MCOI-Zero / AC6-M01」Invasion of Gracemeria

「MCOI-Zero / AC6-M01」Invasion of Gracemeria

Background

Our capital, Gracemeria, is under attack by an unknown force.

The destruction caused by the air raid has spread across the whole city.

All aircraft, scramble immediately to intercept.


"Garuda 1, you are cleared for takeoff."

...

"Garuda 1, take off. Cerberus team, the runway is clear. Take off when ready."

"After all aircraft are airborne, follow AWACS commands."

"This is not a drill. I repeat, this is not a drill!"

...

"This is AWACS Ghost Eye."

...

"Garuda 1, you have no wingman."

"Let me see... Shamrock."

"You are flying solo too, right?"

"Good. From now on, you are Garuda 2."

"Hello, this is Garuda 2."

"No time for introductions. Hurry. Garuda 1, accelerate. I will follow."

"Just give me orders."

"Garuda team, you may now engage the enemy over Gracemeria."

...

"May the Golden King smiles on us!!"

$$_{{\frac{\large\text{ACE COMBAT }\Large6}{\tiny{\text{F i r e s\quad O f\quad L i b e r a t i o n}}}}}\\ \text{Mission 01} \\\Large\text{Invasion Of Gracemeria}\\\tiny -\textit{ Through the Heart Of a Nation }-$$

Problem Description

You are given a sequence aa of length nn, initially all 00, and a positive integer kk.

There are qq operations. Each operation gives i,vi, v, meaning to add vv to the suffix a[i,n]a_{[i,n]} of the sequence aa.

After each operation, output the result of the sum of the kk-th powers of the occurrence counts of all values in the sequence, modulo 2005113120051131.

2005113120051131 is a prime number.

Input Format

The first line contains three integers n,q,kn, q, k.

The next qq lines each contain two integers, representing the operation i,vi, v.

Output Format

Output qq lines, each containing one integer: after this operation, the sum of the kk-th powers of the occurrence counts of all values in the sequence, modulo 2005113120051131.

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 55 occurrences of 11, so the answer is 52=255^2 = 25.

After the second operation, there are 11 occurrence of 11 and 44 occurrences of 22, so the answer is 12+42=171^2 + 4^2 = 17.

Similarly, the answers are 12+12+32=111^2 + 1^2 + 3^2 = 11, 12+12+12+22=71^2 + 1^2 + 1^2 + 2^2 = 7, and 5×12=55 \times 1^2 = 5.


  • Subtask 1 (20 pts): n,q2×103n, q \leq 2 \times 10^3.
  • Subtask 2 (40 pts): n2×103n \leq 2 \times 10^3.
  • Subtask 3 (40 pts): no special constraints.

For 100%100\% of the testdata, it is guaranteed that 1n,v,k200511301 \leq n, v, k \leq 20051130, 1q5×1051 \leq q \leq 5 \times 10^5, and 1in1 \leq i \leq n.

idea: Sol1, solution: Sol1, code: Sol1, data: Sol1 & Xielan Canxiao (pinyin).

Translated by ChatGPT 5