Runtime error in Permutation Swaps ques of may cook off

Hi!
Can somebody tell why am I getting runtime error in the question.
Problem Link:-

My Solution:-
https://www.codechef.com/viewsolution/46832600

Hint :- The problem that I am getting rotates around cnt variable I have defined. I need to do cnt++ which causes the runtime error, but if I replace it with just cnt it shows wrong answer.