plz help i am getting WA bt can’t find where it fails

qstn http://www.codechef.com/problems/TRIP

soltn: http://www.codechef.com/viewsolution/4899723

1)ans[j] array: contain the indices where its stops 1st to get minimum number of intermediate stop

for eg for input

6 3

0

1

3

4

7

10

ans[0]=2(index of 3),ans[1]=3(index of 4),ans[2]=4(index of 4),ans[3]=5(index of 10)

now in second loop i calculate the number of path

finding number of possible node between ans[i] and ans[i+1] which can be taken(it is counted by count variable)(0<=i<=no. of nodes in ans array)to reach arr[ans[i+2]]

now if path between A and B is X and path between B and C is Y then number of path=X.Y(variable mount)