How to optimize my code (CSES Hamiltonian Flights)

Правка en3, от Polyn0mial, 2022-07-01 10:21:28

Link to the problem I use bottom up DP, where $$$dp[\text{mask of visited vertices}][\text{ending vertex}]$$$. I'm pretty sure my time complexity is $$$O(N \cdot 2^N + 2^N \cdot N^2)$$$ however it gives TLE. Are there any way to optimize my code, and what's the reason for TLE (probably big constant factor?)

My code
Теги dp, #hamiltonian-path, graph

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский Polyn0mial 2022-07-01 12:23:19 0 Tiny change: '}\n\n~~~~~\n\n\n</sp' -> '}\n\n~~~~~ \n\n\n</sp'
en3 Английский Polyn0mial 2022-07-01 10:21:28 63 (published)
en2 Английский Polyn0mial 2022-07-01 10:18:47 1050
en1 Английский Polyn0mial 2022-07-01 10:15:25 216 Initial revision (saved to drafts)