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 CodeChef: Practical coding for everyone