MDSWIN2 - Editorial

Once we iterate over an element which should not be in the vector, we delete it, so it’s actually amortized O(sqrt(n)).

The first loop is for calculating modular inverses. The second loop calculates factorials and their inverses.

Anyone tell me please why for any d < Ci makes it X xor Ci xor d becomes 0.
???

I think you missed the previous paragraph before d < Ci, that’s not what the editorial says

In my third submission, I got to know that I require such data structure as mentioned, but couldn’t find it. So I tried many optimizations to tackle the problem.

P.S. To solve such problems, you should have to be an algorithmist and work towards creating something new.
Use faster Hash table
Check my submission Here

1 Like

@rahul_g Nice idea! Could you share the link to your solution?

click

could you explain your sollution with the help of pseudo code.thanks

@tmwilliamlin why this code gives me TLE
https://www.codechef.com/viewsolution/31950164
thanks for such a good editorial.

how to calculate ncr for queries?