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

Автор yoshi_likes_e5, история, 18 часов назад, По-английски

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\leq 10^9,k\leq 4$$$. I solved it using matrix multiplication (converted ARC132C 's transitions to matrix form), 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?

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

»
17 часов назад, # |
  Проголосовать: нравится -6 Проголосовать: не нравится

In this problem k<=4 so it mean that it max take 10^6 and log(n) at max take 10^4.5 we say it is 10^5 but in this problem it takes 10^11 so in long long you may pass it but this is special case. Thank You.