#include #include #include #include using namespace std; const int MAXN = 1005; struct state { int x, y, flag; }; int n, k; int a[MAXN][MAXN]; int x1, y1, x2, y2; queue < state > q; int dist[MAXN][MAXN][2]; pair jump[8] = { {1, 2}, {1, -2}, {-1, 2}, {-1, -2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1} }; bool inside(int x) { if(x>=0 && x " << dist[p.x][p.y][p.flag] << '\n'; for(int i = 0;i<8;i++) { if(inside(p.x+jump[i].first)==true && inside(p.y+jump[i].second)==true && dist[p.x + jump[i].first ][ p.y + jump[i].second ][p.flag^true]==-1 && a[p.x + jump[i].first ][ p.y + jump[i].second ]==0) { dist[p.x + jump[i].first ][ p.y + jump[i].second ][p.flag^true] = dist[p.x][p.y][p.flag] + 1; q.push({p.x + jump[i].first, p.y + jump[i].second, p.flag^true}); } } } } int main() { ios::sync_with_stdio(false); cin.tie(NULL); ifstream cin("chess.in"); ofstream cout("chess.out"); cin >> n >> k; cin >> x1 >> y1; cin >> x2 >> y2; //swap(x1, y1); //swap(x2, y2); //x1 = n - x1 + 1; //x2 = n - x2 + 1; x1--;y1--; x2--;y2--; for(int i = 0;i> a[i][j]; } } BFS(x1, y1); if(dist[x2][y2][k%2]<=k && dist[x2][y2][k%2]!=-1) cout << "Yes" << '\n'; else cout << "No" << '\n'; }