結果

問題 No.240 ナイト散歩
ユーザー hotpepsihotpepsi
提出日時 2016-09-06 00:37:11
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 57,360 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-15 20:31:03
合計ジャッジ時間 1,675 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 29 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>

using namespace std;

int vis[64][64];

void dfs(int x, int y, int d) {
	vis[y][x] = d;
	if (d >= 4) {
		return;
	}
	for (int i = -2; i <= 2; ++i) {
		for (int j = -2; j <= 2; ++j) {
			if (i * j == 2 || i * j == -2) {
				if (!vis[y + i][x + j]) {
					dfs(x + j, y + i, d + 1);
				}
			}
		}
	}
}

int main(int argc, char *argv[]) {
	dfs(32, 32, 1);
	int x, y;
	cin >> x >> y;
	x += 32, y += 32;
	string ans = x >= 0 && x < 64 && y >= 0 && y < 64 && vis[y][x] ? "YES" : "NO";
	cout << ans << endl;
	return 0;
}
0