Help Me With this Interesting problem on permutations.

Revision en3, by Misa-Misa, 2023-10-10 15:53:08

Problem

You are give a permutation of length n. Among all rotations of this permutation find out the one with maximum number of cycles.
Cycles here mean that cyles in the graph of permutation which contains edges from element->corresponding index. (One based indexing)

Constraints:

n <= 3e5

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Misa-Misa 2023-10-10 15:53:08 0 (published)
en2 English Misa-Misa 2023-10-10 15:52:43 21 Tiny change: 'ng index`.<br>\n####' -> 'ng index`. (One based indexing)<br>\n####'
en1 English Misa-Misa 2023-10-10 15:52:12 354 Initial revision (saved to drafts)