G - Caeser Syllables Editorial
by
spheniscine
Additional Note
Note that you actually only need to do the convolutions described in the official editorial for one of the dimensions/variables. For example, first transform the matrix \(B_{i, j} := \) the number of bigrams \([i, j]\) in \(A\), into \(C_{k, j} := \) the number of bigrams \([i, j]\) in \(A\) where \((i + k) \text{ mod } K \notin V\), using fast convolutions. Then you can restore the answer for each \(k\) by summing the entries where \((j + k) \text{ mod } K \in V\).
By the way, if you don’t recognize the input generator, it’s PCG32 (“permuted congruential generator”, 32 bits output, a pseudorandom generator invented by Dr. Melissa O’Neill).
