結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2016-01-17 06:46:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 474 bytes |
コンパイル時間 | 1,225 ms |
コンパイル使用メモリ | 159,420 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 21:19:13 |
合計ジャッジ時間 | 2,130 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;int dx[8] = {-2, -2, -1, -1, +1, +1, +2, +2};int dy[8] = {-1, +1, -2, +2, -2, +2, -1, +1};int X, Y;bool dfs(int y, int x, int depth){if (y == Y && x == X) return true;if (depth == 3) return false;bool res = false;for (int i = 0; i < 8; ++i) res = res || dfs(y + dy[i], x + dx[i], depth + 1);return res;}int main(){cin >> X >> Y;cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;}