__abs's blog

By __abs, history, 23 months ago, In English

Problem statement here. I understood the solution for this.

How to compute the minimum number of rounds required? (this is not asked in that question)

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By __abs, history, 2 years ago, In English

Question. I understand how to solve this using Segment Trees.

I saw this solution by pikmike.

Copied here

Can someone explain how this works?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By __abs, 2 years ago, In English

1.

This solution uses a break statement at the end of for(int i=0; i<n; i++) loop (just after mask -= (1<<i)).
How to "prove" that this break still allows all cases to be tested?

What are some other problems that have this?

2.

What is the time complexity (closed form?)?
My take:
If $$$T(k)$$$ is the time complexity when there are $$$k$$$ zeroes in the mask, then

$$$T(k) = (k-1)T(k-2) + O(n)$$$

(as there are (k-1) choices for j)
Required: $$$T(n)$$$.

$$$T(n) = (n-1)(n-3)...(1) + O(k^2 n)$$$

If that break is removed, then

$$$T(k) = {k \choose 2}T(k-2) + O(n^2)$$$

Full text and comments »

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