I too wrote a brute force algotihm which tested all substrings of length N in 2^N time (bitmask dp, 0 for ‘a’, 1 for ‘b’) and tested upto 24 using manacher’s algorithm for palindrome string length)
@sagijagadish when you write cin.tie(NULL) at the beginning of the code, compiler doesn’t clear the output buffer every time it prints something. Whatever you try to print is stored in the output buffer and printed only once, when the execution of code is finished.
Bonus : Try using endl instead of ‘\n’ in your code. ‘endl’ clears the buffer and add new line at the end.
Sorry, but I’ll see solutions later mate. Writing second part (even longer than the first. Though i hope anyone else on forum might be able to help you even before me.
Hahaha I thought the same thing too ⌈Log2N⌉… I got irritated and randomly kept pressing ‘a’ and ‘b’ and I got a huge string with maximum value four …XD