AT_abc471_g.Caeser Syllables
省选/NOI-
通过率:0%
时间限制:5.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are K kinds of symbols numbered 0 to K−1.
Each symbol is either a vowel or not a vowel. If Vj=1, symbol j is a vowel; if Vj=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 (a1,…,aN) is defined as the number of pairs of integers (l,r) satisfying 1≤l≤r≤N and all of the following:
- The symbols al,…,ar are all vowels.
- If l>1, symbol al−1 is not a vowel.
- If r<N, symbol ar+1 is not a vowel.
You are given a length-N sequence A=(A1,…,AN). For each k=0,…,K−1, answer the following question:
- Define a length-N symbol string A′=(A1′,…,AN′) by Ai′:=(Ai+k)modK. What is the number of syllables of A′?
共有 K 种符号,编号为 0 到 K−1。
每种符号要么是元音,要么不是元音。若 Vj=1,则符号 j 是元音;若 Vj=0,则符号 j 不是元音。
定义一个符号串的音节数为该串中由元音构成的极大连续子串的个数。形式化地,长度为 N 的符号串 (a1,…,aN) 的音节数定义为满足 1≤l≤r≤N 且同时满足以下所有条件的整数对 (l,r) 的个数:
- 符号 al,…,ar 全部为元音;
- 若 l>1,则符号 al−1 不是元音;
- 若 r<N,则符号 ar+1 不是元音。
给定一个长度为 N 的序列 A=(A1,…,AN)。对每个 k=0,…,K−1,回答如下问题:
- 定义长度为 N 的符号串 A′=(A1′,…,AN′),其中 Ai′:=(Ai+k)modK。求 A′ 的音节数。
输入格式
The input is given from Standard Input in the following format:
N K seed M
b1 b2 ⋯ bM
V0 V1 ⋯ VK−1
输入从标准输入中按以下格式给出:
N K seed M
b1 b2 ⋯ bM
V0 V1 ⋯ VK−1
输出格式
Output K lines. The m-th line (1≤m≤K) should contain the answer for k=m−1.
输出 K 行。第 m 行(1≤m≤K)应包含 k=m−1 时的答案。
输入输出样例
输入#1
4 6 12233445577788999 4 4 2 4 1 1 1 0 0 1 0
输出#1
2 0 1 2 1 2
输入#2
15 12 998154573227378904 2 5 6 0 0 1 1 0 1 0 0 1 1 0 1
输出#2
4 4 3 3 3 4 4 4 3 3 3 4
输入#3
7000000 15 409873722375451899 3 7 0 4 1 0 1 1 1 0 1 1 1 0 1 0 1 0 0
输出#3
1680078 1681239 1679837 1680730 1680470 1679454 1679615 1679371 1681263 1679670 1680218 1680010 1680211 1680521 1681744
说明/提示
Input Format
The input for this problem is given in a special format.
Instead of A1,…,AN, the integers seed,M,b1,…,bM are given from Standard Input. Restore A1,…,AN using the computation represented by the following pseudocode.
Here, all variables in the pseudocode are unsigned 64-bit integers. s⊕t denotes the bitwise XOR of s and t, s≫t denotes ⌊s/2t⌋ (the right shift operation), and s≪t denotes s×2t (the left shift operation).
state←seed
for i=1,…,N:
if i≤M:
Ai←bi
else:
x←(((state≫18)⊕state)≫27)mod232
r←state≫59
y←((x≫r)+(x≪(32−r)))mod232
Ai←ymodK
state←(state×6364136223846793005+2026081520260815)mod264
Sample 1 Explanation:
In this input, A=(4,2,4,1).
- For k=0, A′=(4,2,4,1), and the number of syllables is 2.
- For k=1, A′=(5,3,5,2), and the number of syllables is 0.
- For k=2, A′=(0,4,0,3), and the number of syllables is 1.
- For k=3, A′=(1,5,1,4), and the number of syllables is 2.
- For k=4, A′=(2,0,2,5), and the number of syllables is 1.
- For k=5, A′=(3,1,3,0), and the number of syllables is 2.
Sample 2 Explanation:
In this input, A=(5,6,0,6,8,8,8,3,0,2,3,7,3,2,5).
Constraints
- 1≤N≤7×106
- 1≤K≤2300
- 0≤Ai≤K−1 (1≤i≤N)
- Vj∈0,1 (0≤j≤K−1)
- 0≤seed≤260−1
- 1≤M≤min(N,105)
- 0≤bi≤K−1 (1≤i≤M)
- All input values are integers.
输入格式
本题的输入采用特殊格式。
不直接给出 A1,…,AN,而是从标准输入中给出整数 seed,M,b1,…,bM。请使用以下伪代码所表示的计算过程恢复出 A1,…,AN。
其中,伪代码中所有变量均为无符号 64 位整数。s⊕t 表示 s 与 t 的按位异或(XOR),s≫t 表示 ⌊s/2t⌋(右移操作),s≪t 表示 s×2t(左移操作)。
state←seed
for i=1,…,N:
if i≤M:
Ai←bi
else:
x←(((state≫18)⊕state)≫27)mod232
r←state≫59
y←((x≫r)+(x≪(32−r)))mod232
Ai←ymodK
state←(state×6364136223846793005+2026081520260815)mod264
样例 1 解释:
本输入中,A=(4,2,4,1)。
- 当 k=0 时,A′=(4,2,4,1),音节数为 2。
- 当 k=1 时,A′=(5,3,5,2),音节数为 0。
- 当 k=2 时,A′=(0,4,0,3),音节数为 1。
- 当 k=3 时,A′=(1,5,1,4),音节数为 2。
- 当 k=4 时,A′=(2,0,2,5),音节数为 1。
- 当 k=5 时,A′=(3,1,3,0),音节数为 2。
样例 2 解释:
本输入中,A=(5,6,0,6,8,8,8,3,0,2,3,7,3,2,5)。
约束条件
- 1≤N≤7×106
- 1≤K≤2300
- 0≤Ai≤K−1(1≤i≤N)
- Vj∈{0,1}(0≤j≤K−1)
- 0≤seed≤260−1
- 1≤M≤min(N,105)
- 0≤bi≤K−1(1≤i≤M)
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?