Need Hint On This Problem

Pages: 1234567
@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
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) .
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
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.
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
@BugsBunny
is it substring or subsequence ?

@BugsBuuny

take this example

aaabz acoording to ur formula its answer will come 3

but its correct answer is 4..
@ghostrideriit
can you please provide a correct method to do this problem of NSA of codechef.
if anyone expain me test case of equilibrium i can tell him logic of NSA
@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.
@Aman910

What logic u use to clear TLE of no max no min
@aman
can u give little hint for x.
im unable to find the series.
@noobipy

Use nCr=nCn-r property of combination u will not stuck in large value
@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?
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.
But this x can be way too large!

@chitti

Count no. Of elements divisible by m

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

If count 0 print 0
@ Vinn
It's character

@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.........
closed account (iT0i3TCk)
Can anyone give me code for GEARS 100 pts in exchange of full pts EQUILBR / NMNMX
Pages: 1234567