結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2016-03-15 16:17:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 711 bytes |
コンパイル時間 | 679 ms |
コンパイル使用メモリ | 59,700 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 21:22:47 |
合計ジャッジ時間 | 1,481 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,n,0) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 1e8 typedef long long ll; int x, y; bool dfs(int a, int b, int d) { int i; int next[8] = {-2,-1,2,1,2,-1,-2,1}; bool ret = false; if (d > 3) return false; else if (a == x && b == y) return true; else { rep (i,8) ret |= dfs(a+next[i],b+next[(i+1)%8],d+1); return ret; } } int main() { cin >> x >> y; if (dfs(0,0,0)) cout << "YES" << endl; else cout << "NO" << endl; return 0; }