wrong answer in contest humblefool cup qualifiers in the problem two strings

can anyone plzz tell my mistake in my program… it is working correct in code compile and run … https://www.codechef.com/viewsolution/9631769

1 Like

You have not understood this Question correctly. Actually we have to calculate only such no of characters that are different from neighbours.
For example,
Your answer for test case “aba” is 4. But right answer is 8.

2 Likes

My Solution

First we need to find the set of characters in the string which are not same as their neighbouring characters. Then we need to find all the subsets of that set.

So if the number of elements in the set is N then the number of subsets is 2^N.

As N is small (1 ≤ N ≤ 50) so simple brute force would work. Though I have implemented Modular Exponentiation which has a complexity of O(log(N)).

6 Likes
//