[Solution] Palindrome Partition CodeChef Solution
Problem
JJ has a binary string of length . He wants to partition it into substrings such that:
- Each belongs to exactly one partition
- None of the partitioned substrings is a palindrome
For example: One of the valid partitions of is .
Can you find any partition satisfying the above conditions? If no such partition exists, output .
A string is called palindrome if it reads the same backwards and forwards, for e.g. and are palindromic strings.
Input Format
- The first line contains a single integer — the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer — half the length of the binary string .
- The second line of each test case contains a binary string of length containing s and s only.
Output Format
For each test case,
- In the first line, output: - the number of partitions
👇👇👇👇👇
- In the second line, output integers: - where denotes the length of the partitioned substring. (Note that and for all )
Explanation:
Test Case 1: Explained in the problem statement.
Test Case 2: It can be proven that no valid partition of exists.
Test Case 3: One of the valid partitions of is .
No comments:
Post a Comment