#include #include #include #include #include #include using namespace std; bool valid(int new_x, int new_y, int n) { return (new_x >= 0 && new_y >= 0 && new_x < n && new_y < n ); } int knightl(int ii, int jj, int n) { int d[n][n]; int diff [8][2] = {{ii,jj},{-ii,jj},{ii,-jj},{-ii,-jj}, {jj,ii},{-jj,ii},{jj,-ii},{-jj,-ii}}; for(int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { d[i][j] = -1; } } queue < pair > q; q.push(make_pair(0,0)); d[0][0] = 0; while(!q.empty()) { auto it = q.front(); q.pop(); for(int i = 0 ; i < 8 ;i++) { int new_x = it.first + diff[i][0]; int new_y = it.second + diff[i][1]; // cout<< new_x <<" "<< new_y <> n; //cout<< knightl(1,3, n); int a[n-1][n-1]; for (int i = 0; i < n-1 ; i++) { for (int j = i; j < n-1 ; j++) { a[i][j] = knightl(i+1,j+1, n); a[j][i] = a[i][j]; } } for(int i = 0; i < n-1; i++) { cout<