結果
| 問題 | No.240 ナイト散歩 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-26 16:31:09 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 2,000 ms |
| + 390µs | |
| コード長 | 715 bytes |
| 記録 | |
| コンパイル時間 | 287 ms |
| コンパイル使用メモリ | 72,160 KB |
| 実行使用メモリ | 9,780 KB |
| 最終ジャッジ日時 | 2026-09-07 14:22:58 |
| 合計ジャッジ時間 | 1,897 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
using namespace std;
int X, Y;
bool walk(int a, int b, int stepCount) {
if (a == X && b == Y) return true;
if (stepCount == 3) return false;
if (walk(a - 2, b - 1, stepCount + 1)) return true;
if (walk(a - 2, b + 1, stepCount + 1)) return true;
if (walk(a - 1, b - 2, stepCount + 1)) return true;
if (walk(a - 1, b + 2, stepCount + 1)) return true;
if (walk(a + 1, b - 2, stepCount + 1)) return true;
if (walk(a + 1, b + 2, stepCount + 1)) return true;
if (walk(a + 2, b - 1, stepCount + 1)) return true;
if (walk(a + 2, b + 1, stepCount + 1)) return true;
return false;
}
int main() {
cin >> X >> Y;
if (walk(0, 0, 0)) cout << "YES";
else cout << "NO";
}