Codeforces div 3 contest 634

Plz provide the explanation and soln and code of problem E1 and e2 as I wasn’t able to solve and understand from the editorial…plz don’t forward the link of the editorial…

@S19LPPP0202 both the editorial and the solution are present here https://codeforces.com/blog/entry/75993?locale=en

I am not able to understand from the editorial link that is why asked u to provide the soln …and explaination …
Again you have forwarded the link I don’t want the link of editorial.

Plz provide the soln and explaination of your own so that I can understand

@S19LPPP0202 it is a hard problem, if you are unable to understand the logic even after seeing the editorial then I suggest you come back to it later. If you are having trouble understanding any of the syntax in the given solution let me know.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.


Plz.reply to this doubt of mine …as soon as possible it’s already been posted for.a long time now…

Okay , you can post in that discussion , also TA has responded over there, so please check.
I can help you understand the E of [Codeforces div 3 contest 634] over here.

ok explain problem e of codeforces div 3 contest 634 here…

plz reply along with the solution as well…

Ok the solution is of the form (ax)by(ax), where x>=0 and y>=0. Here a and b are possible numbers.
So we’ll try out all possible a’s and smartly choose the best b’s for them.

Precomputation step:-
Make prefix array for the count of all a’s upto for all i in [1,n].
Solution:
Now axbyax , can be seen as 3 blocks, ax ,by and ax. So the number of a’s in the first block is same as 3rd block. Consider some number which we want to use as the number for the first and third blocks. If we take k occurrences in the first block then we also take k occurrences in the third block. Let’s take these occurrences greedily! If we take k elements in the first block (and also in the third block) then it is obviously better to take k leftmost and k rightmost elements correspondingly.

So lets say we have are taking a as 1. And right now we are saying that we will put 2 occurences of 1 in leftmost block, and so 2 occurences of 1 would come in the rightmost block.
Let’s say the corresponding indices are i and j, So it would be best to choose b which has max frequency in the range i to j which can be done using prefix array.

So this is the main idea behind the approach.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

@S19LPPP0202
It seems you have reopened this doubt. One of our TA’s has already provided you with the solution as well as explanation. If your doubt still persists, describe exactly what problem you are facing so we can clear it out.

@S19LPPP0202 hey you have reopened the doubt what is your doubt?Ta has provided solution also.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.