結果

問題 No.240 ナイト散歩
ユーザー Mcpu3
提出日時 2018-12-26 16:29:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 63,136 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-01 14:44:03
合計ジャッジ時間 1,627 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 24 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#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, 1)) cout << "YES";
	else cout << "NO";
}
0