#include #include #include #include #include #include #include #include #include #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define P pair #define MOD 1000000007 #define INF 1012345678 #define NINF (-2147483647-1) #define LLINF 9223372036854775807 using ll = long long; using namespace std; struct C { int x, y; }; int main() { int X, Y; cin >> X >> Y; const int N = 3; //進める回数 const int dx[] = {-2,-2,-1,-1, 1, 1, 2, 2}; const int dy[] = {-1, 1,-2, 2,-2, 2,-1, 1}; vector> visited(4 * N + 1, vector(4 * N + 1, false)); //通った座標の記録 queue> q; q.push(pair(C{0,0}, 0)); while (!q.empty()) { pair p = q.front(); q.pop(); if (visited[p.first.x + 2 * N][p.first.y + 2 * N]) continue; visited[p.first.x + 2 * N][p.first.y + 2 * N] = true; if (p.second < N) { for (int i = 0; i < 8; i++) { q.push(pair(C{p.first.x + dx[i], p.first.y + dy[i]}, p.second + 1)); } } } if (X >= -2 * N && Y >= -2 * N && X <= 2 * N && Y <= 2 * N && visited[X + 2 * N][Y + 2 * N]) { cout << "YES" << endl; } else { cout << "NO" << endl; } // 試しに表示してみる /* for (int i = -2 * N; i <= 2 * N; i++) { for (int j = -2 * N; j <= 2 * N; j++) { if (i == 0 && j == 0) { cout << "%"; } else if (visited[i+2 * N][j+2 * N]) { cout << "#"; } else { cout << "."; } } cout << endl; } */ getchar(); getchar(); return 0; }