Educational Codeforces Round 112 (Rated for Div. 2)

Can Anyone explain the editorial of problem D???
Or if anyone solved it can share his idea and approach …
!>Say No to palindromes.
Problem :Problem - D - Codeforces

1.given string only contain 3 characters
2. notice that if we have palindromes of length(n>3) then we have palindrome of length (n-2) inside it.
3.Here we cannot have 2 same letters side by side.
4.So what i observed is the resultant string is cyclic repetition of (a,b,c)(any order).
5. compute prefix sums and check 6 cases

1 Like