#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; struct position { int x; int y; struct position& operator+=(const position& rhs) { x += rhs.x; y += rhs.y; return *this;} //position operator+(position const& lhs, position const& rhs); }; position operator+(position lhs, const position& rhs) { return lhs += rhs;} /*bool operator==(const position &lhs, const position& rhs) { if (lhs.x==rhs.x && lhs.y==rhs.y){ return } }*/ /* friend std::ostream& operator<< (std::ostream &out, const Point &point); }; std::ostream& operator<< (std::ostream &out, const Point &point) { // Since operator<< is a friend of the Point class, we can access Point's members directly. out << "Point(" << point.m_x << ", " << point.m_y << ", " << point.m_z << ")"; return out; }*/ int main(){ int n; cin >> n; // your code goes here vector> min_steps(n-1, vector(n-1)); // for storing min. no of steps for given KnightL vector moves(8); //vector> visited (n,vector(n,false)); // for marking visited positions, matrix rep. vector present;//(n*n); // for positions reached after current no of steps, list rep. vector future;//(n*n); // for positions reached after current + 1 no of steps int steps = 0; bool reached_finish = false; position next; //position final_position = {n-1,n-1}; for(int a=1; a> visited (n,vector(n,false)); // for marking visited positions, matrix rep. //cout << endl << "Checking Knight(" << a << ","<< b << "):" << endl; present.push_back({0,0}); visited[0][0] = true; steps = 0; reached_finish = false; while(!present.empty()){ ++steps; //cout << endl << "step:" << steps; for (auto pos : present){ //cout << endl << "position (" << pos.x << "," << pos.y << ") check." << endl; for (auto move: moves){ next = pos+move; //cout << "possible next (" << next.x << "," << next.y << ")"; // check if in bounds if(next.x >=0 && next.x =0 && next.y> min_steps(n-1, vector(n-1)); for (int i=0; i