C. Good String

Revision en1, by willtryagain, 2020-08-02 15:28:45

In the problem good string([https://codeforces.com/problemset/problem/1389/C]) I made two observations- i. When n is odd then all characters are equal ii. Else s1 = s3 = ... = sn s2 = s4 = ... = sn-1

It means the string is fixed by the first two starting characters. I iterated from 0 to 9 for the first two characters and found the count of positions- if i is odd and si != s1 or i is even and si != s2

My answer is off by one in some test cases. I want to a small test string where I could find the reason.

Tags #greedy

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English willtryagain 2020-08-02 15:32:27 85 Tiny change: '!= s1 or\n- i i' -> '!= s1 or\n~~~~~\n\n- i i'
en1 English willtryagain 2020-08-02 15:28:45 555 Initial revision (published)