ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2057. Non-palidromic cutting

hint?
Posted by coder 25 Jul 2026 15:15
minimum is  always -1, 1, or 2 ?
1) S = aaaa...aa   => -1        (S = [a]*n)
2) S = aaabaaa   on center different symbol ==> -1 (S = [a]*m + 'b' +[a]*m)
3) S = ababababa...ababa  ==> -1   (S = [ab]*m + 'a' there S is palindrome)
4) S - is not palindrome,  ==> 1
5) S - is palindrome, there at least two different symbols => 2
   Proof 5:
let a = S[1], b = S[i] , and all S[1] = S[2] = ..=S[i-1] = a,  There S is palindrome.
    S = aaaabxy....baaaa
   Take T1 = aaab  T2 = xy...baaaa
   T1 - is not palindrome

    5.1)  T2 also is not palindrome, minimum cut is 2.
    5.2) T2 also palindrome
         5.2.1) i > 2, there two or more 'a' in T1.
           T1 = aaabx   T2 = y....baaaa
          There T1 and T2 both are not palndrome, (think about it).
         5.2.2. i = 2.  T1 = ab  But T2 palindrome, so S = abababababa...aba, this can't be allowed, because S != [ab]*m + 'a'  already checked.