getting wrong answer on spoj SUBST1

any one please help me what’s wrong with my solution:https://ideone.com/fVhCSG
its giving WA running perfectly on my maching

who is he?

I think your suffix array construction takes O(n(logn)^2) time. All the best.