結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2020-02-14 18:24:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 610 bytes |
コンパイル時間 | 521 ms |
コンパイル使用メモリ | 64,108 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-06 09:45:36 |
合計ジャッジ時間 | 1,456 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream>using namespace std;int gx, gy;bool dfs(int x, int y, int depth) {if (depth > 3)return false;if (x == gx && y == gy) return true;return dfs(x - 2, y - 1, depth + 1) ||dfs(x - 2, y + 1, depth + 1) ||dfs(x - 1, y - 2, depth + 1) ||dfs(x - 1, y + 2, depth + 1) ||dfs(x + 1, y - 2, depth + 1) ||dfs(x + 1, y + 2, depth + 1) ||dfs(x + 2, y - 1, depth + 1) ||dfs(x + 2, y + 1, depth + 1);}int main() {cin >> gx >> gy;cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;return 0;}