codeeval 108, 34 in C++
fix perm