Unofficial Editorials November Long Challenge (Part 1)

Nice approach mate. I said there are many approaches, but saw first submission, that didn’t use a string precomputed.

It is given in problem, that N%P = 0

Yes, if u take care of corner cases like P==2 or N == 1.

You just have to count cities which are

For A, Either A, or ‘.’ having ‘A’ on both sides. Same for B.

Refer to my solution for details.