cpp implementation of Palindrome Partitioning II