Блог пользователя __abs

Автор __abs, история, 17 месяцев назад, По-английски

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)

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор __abs, история, 17 месяцев назад, По-английски

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

I saw this solution by pikmike.

Copied here

Can someone explain how this works?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор __abs, 22 месяца назад, По-английски

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)$$$

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится