#include #include using namespace std; int n,k; int x1,y1; int x2,y2; int table[1000][1000]; bool used[1001][1001]; bool c; int dfs(int x,int y,int s) { if(s>k) return 0; //cout<= 0 && y+2<=n) { if(!used[x-1][y+2] && table[x-1][y+2]==0) { if(dfs(x-1,y+2,s+1)==0) return 0; } } if(x-1 >= 0 && y-2 >= 0) { if(!used[x-1][y-2] && table[x-1][y-2]==0) { if(dfs(x-1,y-2,s-1)==0) return 0; } } if(x+2 <= n && y-1 >= 0) { if(!used[x+2][y-1] && table[x+2][y-1]==0) { if(dfs(x+2,y-1,s+1)) return 0; } } if(x+1 <= n && y-2 >= 0) { if(!used[x+1][y-2] && table[x+1][y-2]==0) { if(dfs(x+1,y-2,s+1)==0) return 0; } } if(x-2 >= 0 && y-1 >= 0) { if(!used[x-2][y-1] && table[x-2][y-1]==0) { if(dfs(x-2,y-1,s+1)==0) return 0; } } if(x-2 >= 0 && y+1 <= n) { if(!used[x-3][y+1] && table[x-2][y+1]==0) { if(dfs(x-3,y+1,s+1)) return 0; } } } int main() { freopen("chess.in","r",stdin); freopen("chess.out","w",stdout); ios::sync_with_stdio(false); cin>>n>>k; cin>>x1>>y1>>x2>>y2; for(int i=0; i>table[i][j]; dfs(x1,y1,0); if(c==0) cout<<"No\n"; return 0; }