module main; // 幅優先探索 import std; alias P = Tuple!(int, "x", int, "y"); auto knightMove = [ P(1, 2), P(1, -2), P(-1, 2), P(-1, -2), P(2, 1), P(2, -1), P(-2, 1), P(-2, -1) ]; void main() { // 入力 int X, Y; readln.chomp.formattedRead("%d %d", X, Y); // 答えの計算 int[P] dist; dist[P(0, 0)] = 0; auto que = DList!P(P(0, 0)); while (!que.empty) { P now = que.front; que.removeFront; foreach (m; knightMove) { int nx = now.x + m.x, ny = now.y + m.y; if (P(nx, ny) in dist) continue; int nd = dist[now] + 1; if (nd > 3) // 動けるのは3歩まで continue; dist[P(nx, ny)] = nd; que.insertBack(P(nx, ny)); } } // 答えの出力 writeln(P(X, Y) in dist ? "YES" : "NO"); }