SHIFTPAL- Editorial

OMG THAT WAS SO CUTEE!!

Its motivations like these that keep me going despite a few things <3

2 Likes

I think the problem is that you forgot to add new lines. If there are multiple test cases, all of the results are printed one after another on the same line.

yeah it is… :slight_smile:
thanks to vijju…

I am glad you liked it :slight_smile: . It was written in a rush though XD

Ahhhh… Such lame thing costed me 30-40 mins of contest time :frowning:
Thanks @oconnor_robert :slight_smile:

1 Like

Good question…

1 Like

With “abaabaaba” the answer is 3 and with “abaabaabaabaaba” the answer is 5. Using more than three letters is also possible. With “cbabccbabccbabc” we get 3.

2 Likes

Thank you oconnor_robert :slight_smile:
I am terrible at coming up with test cases. How do you do it? Did you write a program to generate cases?

My first thought was “ababa”. That fails because the a’s at either end up next to each other. From that observation I realised that we need to double the other a’s. Another way to think about it is using your observation. For s = “aaaa” we get 4. If we replace each ‘a’ with a palindrome, we will always get at least 4.

2 Likes

Nice work bro…

“abbaabba” is also interesting and gives 4. This is different than my other examples because there are two unique palindromes that can be formed by shifting this one: “abbaabba” and “baabbaab”.

1 Like

wow, this is amazing! Thank you again :slight_smile:

@vijju123 nice job.

1 Like

Thank you @skyhavoc :slight_smile:

Just to make our lives easier.

2 Likes

These factors depend strictly on your hash function. Check what the setter and tester have done, they did something different. They made it such that, instead of checking if hsh is a multiply of hsh2 or not, they simply checked for hsh1==hsh2. Give a read to editorial if they havent. Try to get what is represented by the hash function, it will be easier to understand it.

Editorial solution is expected to be put up so that we can relate with the editorial. Setter solution has been poorly explained and I couldn’t get the logic behind the setter’s code.
Could you please tell me the logic behind setter’s code?

What do you mean by "Setter solution has been poorly explained". What did you not understand?

I feel the concept is quite sufficiently explained and is easy to understand. Dry run a few iterations to understand.

Editorial solution is expected to be put up so that we can relate with the editorial.

-_- . The editorial explains setter’s and tester’s solution. What do I do then, copy paste setters code?

Could you please tell me the logic behind setter's code?

If such big editorial couldnt help you, I doubt my comment will. Please give more efforts before blaiming.

I still dont understand why do we need to conider n+1 to 3*n-1 range and make increments of 2 while counting the ans ?