|
|
| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | hint? | coder | 2057. Непалиндромное разбиение | 25 июл 2026 15:15 | 1 | hint? coder 25 июл 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.
| | TO ADMIN: the tests are weak. | zimpha | 2057. Непалиндромное разбиение | 6 авг 2016 15:38 | 1 | My brute force solution pass the tests, the run id is 6945666. Maybe you can add more strong tests. |
|
|
|