Not sure. I haven’t solved the problem myself…
Asking someone to explain it to me. (while giving credit)
Though i would try my best to convince that person.
Not sure. I haven’t solved the problem myself…
Asking someone to explain it to me. (while giving credit)
Though i would try my best to convince that person.
I have a doubt @taran_1407
I use the codeblocks ide
whenever i use this code snippet
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
Output is printed after I Give all the Inputs(if there are 4 testcases after i give all tc inputs o/p is printed)
But when i don’t use it Output is Printed after i give the each t.c i/p
Can you tell me why this happens ??
I think you should google this out. That will be better than anything I can explain
Ok Bro and keep up your Good work
There are total of 8-10 such patterns which do it. Though half are asymmetric reflections of each other.
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)
After {2}^{N} thing in complexity, I didnt care for anything else and just wrote a O({N}^{2}) code snippet for palindrome detection.
It was still slow af…(13sec for length of 26) XD
@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.
Nice way. I had said there are many solution to this problem.
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.
Thanks Mate. Glad u liked.
Bonus: endl slows down execution a bit, try to use \n if possible xD
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
You were lucky. I decided spending half an hour messing with random string till i accepted defeat and made tester program
For PERPALIN if(N % P != 0) impossible…
Glad u found them helpful!!.