CODE FESTIVAL 2017 qual C D - Yet Another Palindrome Partitioning

题意

\(n\)长度的小写字符串,问最少分成多少不交段,使得每段都能通过重组回文。\(n\le 2\times 10^5\)

做法

将小写字符串映射为\(2^{i}(i\in [0,26))\),重组回文当且仅当异或值\(=0~or~2^i\)

\(f_i=min\{f_j\}+1(sum_i\oplus sum_j=0~or~2^k)\)\(sum_i\oplus sum_j=0~or~2^k\Longrightarrow sum_i\oplus (0~or~2^k)=sum_j\)

猜你喜欢

转载自www.cnblogs.com/Grice/p/12813596.html