The point values will be 300 — 700 — 700 — 1000 — 1400 — 1600.
Let's discuss problems after the contest.
UPD: Now the editorial (check page 5) is ready.
I'll add some quick comments here.
Try all characters from 'a' to 'z', and assume that we want to get a string that consists only of this character. What greedy strategy should we follow?
Suppose that there are C colors in total. Then, each ai must be either C or C - 1, and it means that the difference between the maximum and the minimum is at most one. Do some case-analysis using this fact.
Suppose that H is not a multiple of h. Put a positive number in a cell if its row-number (0-based) is a multiple of h, otherwise put a negative number. Can you choose the "positive number" and the "negative number" properly?
Create a new cell that keeps the xor of all elements. Each operation can be considered as a swap between this cell and another element in the sequence. Reduce it to a graph problem.
Can you get YES/NO for a given pair of vertices (or more generally, a given set of vertices) in O(M)? Restate it in terms of graphs, then find an O(NM + N3) solution.
The task is about grundy numbers. Can you get O(bellnumber(N)) solution by trying all possible grundy-number sequences? Can you reduce it to O(3N) by DP?