#include #include #include using namespace std; struct P { int x = 0; int y = 0; }; int main() { int jump = 3; int knight = 8; int count = jump; int knight_jump[8][2] = { {1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1},{-2,1},{-1,2} }; bool ans = false; queue q; queue openList; P* input_p = new P; P* start = new P; cin >> input_p->x >> input_p->y; openList.push(start); q.push(start); P* now; int open = 0; while (count > 0) { open = q.size(); for (int i = 0; i < open; i++) { now = q.front(); q.pop(); for (int i = 0; i < knight; i++) { P* point = new P; point->x = now->x + knight_jump[i][0]; point->y = now->y + knight_jump[i][1]; openList.push(point); q.push(point); } } --count; } while (!openList.empty()) { now = openList.front(); ans |= (now->x == input_p->x && now->y == input_p->y); openList.pop(); delete now; } delete input_p; cout << (ans ? "YES" : "NO") << endl; return 0; }