pub fn invert_perm(perm: &[usize]) -> Vec<usize>
Invert a permutation: if perm[i] = j, then result[j] = i.
perm[i] = j
result[j] = i