CLASS ASSIGNMENT shows TLE?

Hi,

How can I avoid generating consecutive ‘B’ combinations (https://ide.codingblocks.com/#/s/19877) for Class Assignment Problem?

(https://hack.codingblocks.com/contests/c/452/875)? It fails with TLE.

Thanks,
Pardeep