BOJACK - Editorial

LOL, its due to this simple observation that I landed 58th rank today!

2 Likes

:frowning: Shattered

Wut :roll_eyes:

No
this problem required you to know that palindromes don’t overlap for distinct characters if substrings are like aaabbbbcc etc…

that wasn’t something you would know unless prior knowledge or if you can see it during the contest… so it was a good problem

aaaaabaaaaa, which is basically DD a’sa’s then a bb and then DD a’sa’s again.

how to count for this??

https://www.codechef.com/viewsolution/35811364
I know my solution is not the most efficient but still can anyone tell me a case where my solution is giving wrong answer?
I would be very grateful if someone tells me the case where WA is coming as I was stuck on this question for almost 2 hours yesterday.

1 Like

ya bro i think ur sol is correct … i also tried to solve by this approach but got wrong ans … if u get any further information please update me

my code link

my code is correct i have checked it on all the testcase …
please look into the matter

Yes I think only the two approaches which are mentioned in the editorial are considered correct but I just want clarity regarding whether my solution is correct or not.

i just messed up the things

i checked my sol for all the values of D and its correct

Same feeling… :frowning:

You have D’s a and D’s b. Number of substrings if you take only a’s will be D, similarly for b.
Now you want to choose such a substring[l...r]s.t l is somewhere in the a-th segment and r is somewhere in the b-th segment, Number of such substrings will be D choose 1 * D choose 1. So, total = D*D + D + D. :slightly_smiling_face:

2 Likes

For n=4 ,. D=2*4 + 1 aaaabaaaa

Distinct substring - 29
a,b , aaaabaaaa, aaaabaaa,aaaabaa,aaaaba, aaaab, aaaa, aaa ,aa , aaabaaaa, aaabaaa, aaabaa, aaaba, aaab, aabaaaa, aabaaa, aabaa, aaba ,aab , abaaaa, abaaa,abaa , aba ,baaaa, baaa ,baa, ba ,ab

Palindromic substring -
25
a*8, b , aaaa, aaaa, aa , aa, aa ,aa,aa,aa , aaa ,aaa ,aaa, aaa, aba, aabaa, aaabaaa, aaaabaaaa,

Hi! Can anyone help me with this?

For D = 2. How is the answer ‘aabb’. Because

Distinct strings are: a b aa bb ab aab abb aabb
Panlindromic strings are: a b aa bb

Hence, the difference in not 2 as it should have been. How is this solution correct then?
Is there something that I am missing? Please help, TIA.

CodeChef: Practical coding for everyone.
My solution is a lesson that please read question carefully(o/p format).

Palindromic Substrings will be a, a, aa, b, b, bb.(6 in total)

I don’t understand why my solution for the problem gives WA.
I have tested it a couple of times and it gives the correct output for all the cases.

My solution @ CodeChef: Practical coding for everyone

Trial and error

:joy: :joy: :joy: :joy: