i,j in each operation, and then swap the values of. k operations, we construct an undirected graph with. In the initial state, there are no edges in the graph. then, for each
There is a permutation p_1, p_2... p_n p 1 ,p 2 ...p n (it is guaranteed that 1,2...,n 1,2...,n occurs exactly once in permutation p p) Now we need to do exactly k k operations, select two different positions i, j i,j in each operation, and then swap the values of p_i p i and p_j p j . After k k operations, we construct an undirected graph with n n points labeled 1,2,...n 1,2,...n In the initial state, there are no edges in the graph. then, for each i i from 1 1 to n n, we connect an undirected edge between i i and p_i p i . Find the minimum number of connected components.