Is there any general algorithm?

Revision en3, by i_love_sqrt_decomp, 2025-05-05 12:48:24

Is there an algorithm that solves this problem for any $$$k$$$? https://codeforces.me/problemset/gymProblem/101806/X.

Any complexity is allowed, if it solves the problem for $$$k\leq5$$$ with the original constraints.

Spoiler

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English i_love_sqrt_decomp 2025-05-05 12:48:24 5 Tiny change: 'g at most O(m) iteration' -> 'g at most $m$ iteration'
en2 English i_love_sqrt_decomp 2025-05-05 12:48:12 32 Tiny change: 'th problem, which is' -> 'th problem using at most O(m) iterations, which is'
en1 English i_love_sqrt_decomp 2025-05-05 12:45:19 391 Initial revision (published)