#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; int gcd(int a, int b); int main(){ int n; cin >> n; // your code goes here for( int i=1; i< n; i++){ for( int j=1; j< n; j++){ bool visited[n][n]; int distance[n][n]; for( int y=0; y -1 ){ visited[y1][x1] = true; for( int m=-1; m<=1; m+=2){ for( int p=-1; p<=1; p+=2){ int newposx = x1 + (p*i); int newposy = y1 + (m*j); if(( newposx >= 0 && newposx = 0 && newposy cDist + 1 || distance[newposy][newposx]==-1){ distance[newposy][newposx] = cDist + 1; } } } } // Switch moves for( int m=-1; m<=1; m+=2){ for( int p=-1; p<=1; p+=2){ int newposx = x1 + (p*j); int newposy = y1 + (m*i); if(( newposx >= 0 && newposx = 0 && newposy cDist + 1 || distance[newposy][newposx]==-1){ distance[newposy][newposx] = cDist + 1; } } } } }else{ if( distance[n-1][n-1] == -1){ cout<< "-1 "; }else{ cout<