Note: This is an approximate problem. There is no exact solution. You must find the most optimal solution. Please refer to the sample explanation to ensure that you understand the problem correctly.
Problem statement
You are given a string of length consisting of lowercase Latin characters (). You are required to decompose into consecutive non-empty substrings such that every character is present in only one substring.
If substrings are , then select an array that is a permutation of 1 to denoting that it is of size and include every element from 1 to .
Your are required to form a new string .
Note: The number of palindromic substrings in is (of length greater than 1).
Your task is to maximize .
Input format
Output format
Verdict and scoring
Constraints
S1 = ab
S2 = ab
V = S[B[1]] + S[B[2]] = S[2] + S[1] = ab + ab = abab
Number of substrings which are palindromic = 2
Z = 2
Sample Test is for understanding purpose. Constraints in test files are as mentioned above.