#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define MOD 1000000009 int main(){ static int dx[8]={-2, -2, -1, -1, 1, 1, 2, 2}; static int dy[8]={-1, 1, -2, 2, -2, 2, -1, 1}; int x,y; cin>>x>>y; queue qx,qy,qc; qx.push(0); qy.push(0); qc.push(0); while(!qx.empty()){ int x1 = qx.front();qx.pop(); int y1 = qy.front();qy.pop(); int c1 = qc.front();qc.pop(); if(c1>3)continue; if(x1==x&&y1==y){ cout << "YES" << endl; return 0; } rep(i,0,8){ qx.push(x1+dx[i]); qy.push(y1+dy[i]); qc.push(c1+1); } } cout << "NO" << endl; return 0; } /* 幅優先探索か深さ3で打ち切りの深さ優先探索でいけると思います。 */