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

Автор greateric, история, 7 дней назад, По-английски

Think FFT doesn't matter? You're probably right I found an unintended extra speedup to a div 2 E that I thought was funny.

I was practicing and came across 2025E while practicing, a 2200 problem from an educational div2.

If you want, try the problem yourself. Then suppose $$$m = 1000, n = 1000$$$, and see if you can solve it in faster than cubic time.


This is my cubic solution (read this even if you've solved it yourself/seen the editorial since I thought of a slightly different way to do it)

Answer

Now for the fun part.

FFT
Теги fft
  • Проголосовать: нравится
  • +26
  • Проголосовать: не нравится

»
7 дней назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by greateric (previous revision, new revision, compare).

»
7 дней назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

you can optimise the convolution portion further: notice that you are convolving dp2 with itself n times (dp is initially [1, 0, 0, ..., 0, 0] which is the identity element for convolutions). Write that as (dp2)^N. The convolution operation is commutative, so you can compute (dp2)^N using binary exponentiation. for n <= 500 this means you can compute the final answer in just 9(!) FFTs. (also because dp2 is just catalan numbers you can solve the whole problem in O(m + 9mlogm) = O(mlogm))

»
6 дней назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится