RRSTONE may long challenge help

I’ve tried solving RRSTONES considering all corner cases but still getting WA. Can anyone please tell me where I am going amiss.
here is my code http://www.codechef.com/viewsolution/3855501