Problem Solving

question:https://www.codechef.com/JULY20B/problems/CHFNSWPS
my soln:https://ide.codingblocks.com/s/279455
I know its a live contest but please help sir and check my approach

other way of finding the map