Sum of Mex of Mod of LinearAI (CI翻译)
Problem Statement
You are given integers $N,M,C,K$ and an integer sequence $A=(A_1,A_2,\ldots,A_N)$ of length $N$.
You are given $Q$ queries, which you should process in order. The $q$-th $(1\le q\le Q)$ query gives integers $i_q,X_q$, and you should solve the following problem after changing $A_{i_q}$ to $X_q$.
Find the value of
$\displaystyle \sum_{k=0}^{K-1} \mathop{\mathrm{mex}}\limits_{1 \le i \le N} \lbrace (Ck+A_i)\bmod M\rbrace$. Here,$\displaystyle \mathop{\mathrm{mex}}\limits_{1 \le i \le N} B_i$denotes the smallest non-negative integer not contained in$B$, for an integer sequence$B=(B_1,B_2,\ldots,B_N)$.
Constraints
$1\le N\le 2\times 10^5$$0\le C < M \le 10^9$$1\le K\le 10^9$$0\le A_i < M$$1\le Q\le 2\times 10^5$$1\le i_q \le N$$0\le X_q < M$- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M C K
A_1 A_2 \ldots A_N
Q
i_1 X_1
i_2 X_2
\vdots
i_Q X_Q
Output
Output $Q$ lines.
The $q$-th line $(1\le q\le Q)$ should contain the answer to the problem after processing the $q$-th query.
{"titleZh":"线性函数取模的 Mex 之和","bodyZh":"## 题目描述\n\n给定整数 $N,M,C,K$,以及一个长度为 $N$ 的整数序列 $A=(A_1,A_2,\\ldots,A_N)$。\n\n现在有 $Q$ 次查询,请按顺序处理。第 $q$ 次 $(1\\le q\\le Q)$ 查询给出整数 $i_q,X_q$,将 $A_{i_q}$ 修改为 $X_q$ 后,请解决以下问题。\n\n> 求 $\displaystyle \\sum_{k=0}^{K-1} \\mathop{\\mathrm{mex}}\\limits_{1 \\le i \\le N} \\lbrace (Ck+A_i)\\bmod M\\rbrace$ 的值。其中,对于整数序列 $B=(B_1,B_2,\\ldots,B_N)$,$\displaystyle \\mathop{\\mathrm{mex}}\\limits_{1 \\le i \\le N} B_i$ 表示 $B$ 中未出现的最小非负整数。\n\n## 约束条件\n\n- $1\\le N\\le 2\\times 10^5$\n- $0\\le C < M \\le 10^9$\n- $1\\le K\\le 10^9$\n- $0\\le A_i < M$\n- $1\\le Q\\le 2\\times 10^5$\n- $1\\le i_q \\le N$\n- $0\\le X_q < M$\n- 所有输入值均为整数。\n\n## 输入格式\n\n输入从标准输入按以下格式给出:\n\n\n\n## 输出格式\n\n输出 \nN M C K\nA_1 A_2 \\ldots A_N\nQ\ni_1 X_1\ni_2 X_2\n\\vdots\ni_Q X_Q\n$Q$ 行。\n\n第 $q$ 行 $(1\\le q\\le Q)$ 应包含处理完第 $q$ 次查询后的问题答案。"}AI (CI翻译)
样例
2 3 1 2
0 2
3
2 2
1 1
2 1
3
1
0
7 9 3 19
7 0 2 8 1 3 4
7
3 5
1 6
3 2
5 5
4 7
7 8
2 4
32
44
53
37
49
37
54
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。