#ABC471G. 凯撒音节 / Caeser Syllables

凯撒音节 / Caeser Syllables

题目描述

There are KK kinds of symbols numbered 00 to K1K-1.

Each symbol is either a vowel or not a vowel. If Vj=1V_j = 1, symbol jj is a vowel; if Vj=0V_j = 0, symbol jj 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-NN symbol string (a1,,aN)(a_1, \dots, a_N) is defined as the number of pairs of integers (l,r)(l,r) satisfying 1lrN1 \leq l \leq r \leq N and all of the following:

  • The symbols al,,ara_l, \dots, a_r are all vowels.
  • If l>1l > 1, symbol al1a_{l-1} is not a vowel.
  • If r<Nr < N, symbol ar+1a_{r+1} is not a vowel.

You are given a length-NN sequence A=(A1,,AN)A = (A_1, \dots, A_N). For each k=0,,K1k = 0, \dots, K-1, answer the following question:

  • Define a length-NN symbol string A=(A1,,AN)A' = (A'_1, \dots, A'_N) by Ai:=(Ai+k)modKA'_i := (A_i + k) \bmod K. What is the number of syllables of AA'?

输入格式

The input is given from Standard Input in the following format:

  • NN KK seed\mathrm{seed} MM
  • b1b_1 b2b_2 \cdots bMb_M
  • V0V_0 V1V_1 \cdots VK1V_{K-1}

输出格式

Output KK lines. The mm-th line (1mK1 \leq m \leq K) should contain the answer for k=m1k = m-1.

数据范围

  • 1N7×1061 \leq N \leq 7 \times 10^6
  • 1K23001 \leq K \leq 2300
  • 0AiK10 \leq A_i \leq K-1 (1iN1 \leq i \leq N)
  • Vj{0,1}V_j \in \{0,1\} (0jK10 \leq j \leq K-1)
  • 0seed26010 \leq \mathrm{seed} \leq 2^{60} - 1
  • 1Mmin(N,105)1 \leq M \leq \min(N, 10^5)
  • 0biK10 \leq b_i \leq K-1 (1iM1 \leq i \leq M)
  • All input values are integers.
4 6 12233445577788999 4
4 2 4 1
1 1 0 0 1 0
2
0
1
2
1
2

In this input, A=(4,2,4,1)A = (4,2,4,1).

  • For k=0k = 0, A=(4,2,4,1)A' = (4,2,4,1), and the number of syllables is 22.
  • For k=1k = 1, A=(5,3,5,2)A' = (5,3,5,2), and the number of syllables is 00.
  • For k=2k = 2, A=(0,4,0,3)A' = (0,4,0,3), and the number of syllables is 11.
  • For k=3k = 3, A=(1,5,1,4)A' = (1,5,1,4), and the number of syllables is 22.
  • For k=4k = 4, A=(2,0,2,5)A' = (2,0,2,5), and the number of syllables is 11.
  • For k=5k = 5, A=(3,1,3,0)A' = (3,1,3,0), and the number of syllables is 22.
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

In this input, A=(5,6,0,6,8,8,8,3,0,2,3,7,3,2,5)A = (5, 6, 0, 6, 8, 8, 8, 3, 0, 2, 3, 7, 3, 2, 5).

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

补充说明

Input Format

The input for this problem is given in a special format.

Instead of A1,,ANA_1, \dots, A_N, the integers seed,M,b1,,bM\mathrm{seed}, M, b_1, \dots, b_M are given from Standard Input. Restore A1,,ANA_1, \dots, A_N using the computation represented by the following pseudocode.

Here, all variables in the pseudocode are unsigned 6464-bit integers. sts \oplus t denotes the bitwise XOR of ss and tt, sts \gg t denotes s/2t\lfloor s / 2^t \rfloor (the right shift operation), and sts \ll t denotes s×2ts \times 2^t (the left shift operation).

state <- seed

for i = 1, ..., N:
    if i <= M:
        A_i <- b_i
    else:
        x <- (((state >> 18) XOR state) >> 27) mod 2^32
        r <- state >> 59
        y <- ((x >> r) + (x << (32-r))) mod 2^32
        A_i <- y mod K
        state <- (state * 6364136223846793005 + 2026081520260815) mod 2^64