Runtime Error(SIGSEGV):Memory 1500M

Can anyone pls help with 1500M memory with my code for Fire Escape Route
http://www.codechef.com/viewsolution/2592210