#include using namespace std; int findDistance(int i_s,int j_s,int i_e,int j_e){ return abs(i_e - i_s) + abs(j_e - j_s); } void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end,string pos) { // Print the distance along with the sequence of moves. static int distance_to_goal = 0,current_step = 0,prev_distance_to_goal = 1000; static vector path; static int flag = 0; distance_to_goal = findDistance(i_start,j_start,i_end,j_end); static int expected_steps = (distance_to_goal%3 == 0)?(distance_to_goal/3):(distance_to_goal/3 + 1); //cout<<"CS: ES: Is: Js: Ie: Je: DTG: PDTG:"< n || j_start > n) return; if(distance_to_goal == 0){ if(current_step == expected_steps - 1){ path.push_back(pos); current_step++; cout<::iterator i=path.begin()+1;i> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end,""); return 0; }