// No.240 ナイト散歩 // https://yukicoder.me/problems/no/240 // #include #include #include #include #include #include using namespace std; string solve(int gx, int gy, int step); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int X, Y; cin >> X >> Y; string ans = solve(X, Y, 3); cout << ans << endl; } struct Pos { int x; int y; }; string solve(int gx, int gy, int step) { vector moves {{-2, -1}, {-2, 1}, {-1, -2}, {-1, 2}, {1, -2}, {1, 2}, {2, -1}, {2, 1}}; int cx = 0; int cy = 0; deque> que; que.push_back(make_pair(Pos{cx, cy}, step)); while (!que.empty()) { pair t = que.front(); que.pop_front(); cx = t.first.x; cy = t.first.y; step = t.second; if (step > 0) { for (auto d: moves) { int nx = cx + d.x; int ny = cy + d.y; if (nx == gx && ny == gy) return "YES"; que.push_back(make_pair(Pos{nx, ny}, step - 1)); } } } return "NO"; }