SADMAN's blog

By SADMAN, history, 7 months ago, In English

I was trying this problem 840D - Destiny using Mo's algorithm but I got stuck on TLE on test 5 342080782 for using map . Is there any alternative way to solve this problem using Mo's Algorithm?

  • Vote: I like it
  • +2
  • Vote: I do not like it

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I think that Mo should give TLE because there is a clean O(KNlogN) approach you can also check 2149G - Buratsuta 3 from a recent contest

  • »
    »
    7 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    Bro i solve it . Actually after the mos algos work the main game played by the probability. Here probability comes cause k<=5 . So the chance of picking any random frequency to be correct answer is so high because 1/5 is 20% . Why 1/5 cause frequency> len/k To turn this into a proportion (or probability), we divide both sides ->frequency/len > (len/k) / len -> frequency/len > 1/ k so 1/ k means 1/5 is 20% . 20% maybe not so big amount but if we do till 100 times it's guaranteed that it will give us correct ans .

    Let's use an analogy. Imagine you have a special five-sided die, and you win if you roll a "1" - Chance of winning on one roll: 1 in 5, or 20%. (Not great) - Chance of losing on one roll: 4 in 5, or 80%. Now, what if 100 times? What's the chance you lose every single time? The probability of losing 100 times in a row is: (4/5)×(4/5)×(4/5)......…100 times =(4/5)^100 ≈0.8^100 This number is 0.000000000000000000000008. It is so close to zero that it's practically impossible to lose every time.

    This means your chance of winning at least once in 100 tries is: 1−(chance of losing every time)≈99.999999999999999999999992%

    So, by repeating a 20% chance enough times, we've turned it into a near certainty. For more understanding you can check my submission 342148924

    Same solution for the problem which you mentioned G of the recent contest.