Complexity of permutation problem

Правка en1, от yoshi_likes_e5, 2025-03-05 04:17:42

There is a problem that I solved earlier: Find how many permutations p s.t. $$$|p_i-i|\leq k$$$ for all $$$i$$$. Constraints: $$$n<=10^9,k<=4$$$. I solved it using matrix multiplication, but naively multiplying the matrix creates the insane complexity of $$$O(64^k*\log(n))$$$. By skipping the non-zero terms in the left hand side, I was able to get it passed. Can anyone explain why this passes, and maybe prove the complexity of it?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский yoshi_likes_e5 2025-03-05 04:18:59 117 Tiny change: '/arc132_c)'s transit' -> '/arc132_c) 's transit'
en1 Английский yoshi_likes_e5 2025-03-05 04:17:42 451 Initial revision (published)