getting wa SPOJ AMBLE

SPOJ.com - Problem AMBLE A4tpoW - Online C++0x Compiler & Debugging Tool - Ideone.com
I am taking the forward path element before the current place and reverse path element