Need Hint On This Problem

Pages: 1234567
Jul 10, 2018 at 11:18am
@noobipy
Check for the number of different character appearing in your string (it can be easily incorporated with help of sets or hash maps). To further reduce your operations, if the character coming just after the character-which-you-are-altering, differs from it by a difference greater than your till best result, you can ignore the rest of the characters for that particular case.
But, this still gives TLE for the task 4 of subtask 3.
Last edited on Jul 10, 2018 at 11:19am
Jul 10, 2018 at 2:40pm
closed account (iGEqDjzh)
@kr002 that is the exact problem I am facing in handling those large numbers:(. What is your exact code complexity ? Well I can reduce mine to n^2 but only if those Big Ints operation take O(1) .
Jul 10, 2018 at 3:35pm
closed account (iGEqDjzh)
@Kr002 I have done the precomputation thing already to reduce my complexity but it still gives me TLE in second subtask in python.
And as far as wrong ans are concerned I don't think it is is due to overflow because if you are able to store nCr for all values then how can be there an overflow while calculating their powers as we then have to use mod at each step!!!
Last edited on Jul 10, 2018 at 3:36pm
Jul 10, 2018 at 4:04pm
closed account (iGEqDjzh)
Don't store it in modulo with prime, python supports BigInts, store it as it is and then try submitting the code and let me know if you pass all the subtasks.
Jul 10, 2018 at 4:17pm
closed account (iGEqDjzh)
Your system might crashed (didn't responded) because may be you were trying to print that value.Do one thing make a factorial array in which F[i] = factorial of i. Store the factorials for all the numbers till 5000 and then see if your system crashes or not
Jul 11, 2018 at 9:55am
@BugsBunny
is it substring or subsequence ?
Jul 11, 2018 at 10:03am

@BugsBuuny

take this example

aaabz acoording to ur formula its answer will come 3

but its correct answer is 4..
Jul 11, 2018 at 10:44am
@ghostrideriit
can you please provide a correct method to do this problem of NSA of codechef.
Jul 11, 2018 at 12:28pm
if anyone expain me test case of equilibrium i can tell him logic of NSA
Jul 11, 2018 at 12:30pm
@kashish
if you want solution and also with explnation then give me the solution for NSA , don't worry i will not copy the code.
so pm me.
Jul 11, 2018 at 4:00pm
@Aman910

What logic u use to clear TLE of no max no min
Jul 11, 2018 at 6:19pm
@aman
can u give little hint for x.
im unable to find the series.
Jul 11, 2018 at 6:23pm
@noobipy

Use nCr=nCn-r property of combination u will not stuck in large value
Jul 11, 2018 at 6:36pm
@ghostrider would the inclusion exclusion principle work?I mean I know it will give the correct answer but it seems as if it would take a lot of time...For each element, I will have to add a total of min(i,n-i) nCr's where n is the number of elements and i is the i'th element's index in array.Would it work?
Jul 11, 2018 at 6:55pm
I think this may led to TLE using combination u need to only check till n/2Cr ...

As Aman told u will get a pattern for a[I]^xi , so use pow(x,a[I]*a[n-i]) till half loop.
Jul 11, 2018 at 8:09pm
But this x can be way too large!
Jul 12, 2018 at 6:26am

@chitti

Count no. Of elements divisible by m

Use result=pow(2,count)-1; if count>0

If count 0 print 0
Jul 12, 2018 at 6:27am
@ Vinn
It's character
Jul 12, 2018 at 6:43am

@codator

ya u can put it or not ur wish both thing are same

Ya, no maximum no minimum is a combination problem u take some example and u found

a multiplication relation between a[i+1] and a[n-i] element and think.........
Jul 12, 2018 at 7:05am
closed account (iT0i3TCk)
Can anyone give me code for GEARS 100 pts in exchange of full pts EQUILBR / NMNMX
Pages: 1234567