Help!!! how to solve UVA online judge 10128 — Queue

Revision en1, by abhatter, 2021-02-05 19:25:52

Hello, I am trying to generate all permutations and for each permutation I am checking if the given conditions are satisfied and then counting it as part of the solution. But this approach times out as the time complexity is n*n!

I am not able to understand as to what can be precomputed.

Any help is appreciated.

Click for problem link

Thanks in advance

Tags #dynamic programing

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English abhatter 2021-02-05 19:25:52 530 Initial revision (published)