UVA 11553 :: GRID
Going through all permutation as test input is small. this is JAVA solution. its time limit exceeds , you will get accept in C++ use next_permutation function. this code is nice to see how actual permutation would be designed.
Problems has to be addressed else its state will be same or it will be more bitter but never be in a solved position.