Your process()
function will populate globalmap
such that the cycle length of 1 is 1, but your cyclelength
function returns a cycle length of 0 if passed in ll = 1
and ans = 0
.
So, on the following input:
1 1
1 2
Your program will output:
1 1 0
1 2 2
This seems like it might be the sticking point with your sol'n.