Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

shaaban_abdelrahim's blog

By shaaban_abdelrahim, history, 12 months ago, In English

What is the best B to use in 3D/4D MO?

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

»
12 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

The time complexity of k-dimensional Mo's is $$$O(q * B + (n/B)^{k-1}n)$$$ (assuming $$$k$$$ is a constant). Choosing $$$B = O(n / q^{1/k})$$$ gives a time complexity of $$$n \cdot q^{1-1/k}$$$. See https://codeforces.me/blog/entry/61203?#comment-451304 for more information and proof of the $$$n \cdot q^{1-1/k}$$$ lower bound.

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

If you do 4d mo, just write a quadratic solution with good constant factor, and it will be faster