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
Auto comment: topic has been updated by Misa-Misa (previous revision, new revision, compare).