Unofficial Editorials November Long Challenge (Part 1)

I think you should google this out. That will be better than anything I can explain :smiley:

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.

2 Likes

Thanks Mate. @sagijagadish

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.

@droy0528, second part posted. There’s a bit of delay even in delay gift :slight_smile:

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 :smiley:

For PERPALIN if(N % P != 0) impossible…

Glad u found them helpful!!.

Nice approach mate. I said there are many approaches, but saw first submission, that didn’t use a string precomputed.

It is given in problem, that N%P = 0

Yes, if u take care of corner cases like P==2 or N == 1.

You just have to count cities which are

For A, Either A, or ‘.’ having ‘A’ on both sides. Same for B.

Refer to my solution for details.