Caeser SyllablesAI (CI翻译)
Problem Statement
There are $K$ kinds of symbols numbered $0$ to $K-1$.
Each symbol is either a vowel or not a vowel. If $V_j = 1$, symbol $j$ is a vowel; if $V_j = 0$, symbol $j$ is not a vowel.
Define the number of syllables of a symbol string as the number of maximal contiguous substrings of that string consisting of vowels. Formally, the number of syllables of a length-$N$ symbol string $(a_1, \dots, a_N)$ is defined as the number of pairs of integers $(l,r)$ satisfying $1 \leq l \leq r \leq N$ and all of the following:
- The symbols
$a_l, \dots, a_r$are all vowels. - If
$l > 1$, symbol$a_{l-1}$is not a vowel. - If
$r < N$, symbol$a_{r+1}$is not a vowel.
You are given a length-$N$ sequence $A = (A_1, \dots, A_N)$. For each $k = 0, \dots, K-1$, answer the following question:
- Define a length-
$N$symbol string$A' = (A'_1, \dots, A'_N)$by$A'_i := (A_i + k) \bmod K$. What is the number of syllables of$A'$?
Input
The input for this problem is given in a special format.
Instead of $A_1, \dots, A_N$, the integers $\mathrm{seed}, M, b_1, \dots, b_M$ are given from Standard Input. Restore $A_1, \dots, A_N$ using the computation represented by the following pseudocode.
Here, all variables in the pseudocode are unsigned $64$-bit integers. $s \oplus t$ denotes the bitwise XOR of $s$ and $t$, $s \gg t$ denotes $\lfloor s / 2^t \rfloor$ (the right shift operation), and $s \ll t$ denotes $s \times 2^t$ (the left shift operation).
\mathrm{state} \leftarrow \mathrm{seed}
for i = 1, \dots, N:
if i \leq M:
A_i \leftarrow b_i
else:
x \leftarrow \left( ((\mathrm{state} \gg 18) \oplus \mathrm{state}) \gg 27 \right) \bmod 2^{32}
r \leftarrow \mathrm{state} \gg 59
y \leftarrow \left( (x \gg r) + (x \ll (32-r)) \right) \bmod 2^{32}
A_i \leftarrow y \bmod K
\mathrm{state} \leftarrow (\mathrm{state} \times 6364136223846793005 + 2026081520260815) \bmod 2^{64}
Constraints
$1 \leq N \leq 7 \times 10^6$$1 \leq K \leq 2300$$0 \leq A_i \leq K-1$($1 \leq i \leq N$)$V_j \in \{0,1\}$($0 \leq j \leq K-1$)$0 \leq \mathrm{seed} \leq 2^{60} - 1$$1 \leq M \leq \min(N, 10^5)$$0 \leq b_i \leq K-1$($1 \leq i \leq M$)- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K \mathrm{seed} M
b_1 b_2 \cdots b_M
V_0 V_1 \cdots V_{K-1}
Output
Output $K$ lines. The $m$-th line ($1 \leq m \leq K$) should contain the answer for $k = m-1$.
{"titleZh":"凯撒音节","bodyZh":"## 题目描述\n\n有 $K$ 种符号,编号为 $0$ 至 $K-1$。\n\n每种符号要么是元音,要么不是元音。若 $V_j = 1$,则符号 $j$ 是元音;若 $V_j = 0$,则符号 $j$ 不是元音。\n\n定义一个符号串的音节数为该字符串中由元音组成的极大连续子串的数量。形式化地,对于一个长度为 $N$ 的符号串 $(a_1, \dots, a_N)$,其音节数定义为满足以下所有条件的整数对 $(l,r)$ 的数量,其中 $1 \leq l \leq r \leq N$:\n\n- 符号 $a_l, \dots, a_r$ 全部是元音。\n- 若 $l > 1,则符号 $a_{l-1}$ 不是元音。\n- 若 $r < N,则符号 $a_{r+1}$ 不是元音。\n\n给定一个长度为 $N$ 的序列 $A = (A_1, \dots, A_N)$。对于每个 $k = 0, \dots, K-1$,请回答以下问题:\n\n- 定义长度为 $N$ 的符号串 $A' = (A'_1, \dots, A'_N)$,其中 $A'_i := (A_i + k) \\bmod K$。$A'$ 的音节数是多少?\n\n## 输入格式\n\n本题的输入采用特殊格式。\n\n标准输入中并不直接给出 $A_1, \dots, A_N$,而是给出整数 $\\mathrm{seed}, M, b_1, \dots, b_M$。请根据以下伪代码所表示的计算过程还原 $A_1, \dots, A_N$。\n\n在以下伪代码中,所有变量均为无符号 64 位整数。$s \\oplus t$ 表示 $s$ 与 $t$ 的按位 XOR,$s \\gg t$ 表示 $\\lfloor s / 2^t \\rfloor$(右移操作),$s \\ll t$ 表示 $s \\times 2^t$(左移操作)。\n\n
- $0 \\leq b_i \\leq K-1$($1 \\leq i \\leq M$)
- 所有输入值均为整数。\n\n## 输入格式\n\n输入从标准输入按以下格式给出:\n\n\nN K \mathrm{seed} M\nb_1 b_2 \cdots b_M\nV_0 V_1 \cdots V_{K-1}\n```\n\n## 输出格式\n\n输出 $K$ 行。第 $m$ 行($1 \\leq m \\leq K$)应包含 $k = m-1$ 时的答案。"}AI (CI翻译)
样例
4 6 12233445577788999 4
4 2 4 1
1 1 0 0 1 0
2
0
1
2
1
2
15 12 998154573227378904 2
5 6
0 0 1 1 0 1 0 0 1 1 0 1
4
4
3
3
3
4
4
4
3
3
3
4
7000000 15 409873722375451899 3
7 0 4
1 0 1 1 1 0 1 1 1 0 1 0 1 0 0
1680078
1681239
1679837
1680730
1680470
1679454
1679615
1679371
1681263
1679670
1680218
1680010
1680211
1680521
1681744
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。