結果

問題 No.240 ナイト散歩
ユーザー femto
提出日時 2015-12-21 01:51:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 58,536 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 21:14:07
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 24 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
using namespace std;

bool board[4][10][10];

int main() {
	int x, y;
	cin >> x >> y;
	x = abs(x), y = abs(y);

	if(x > 10 || y > 10) {
		cout << "NO" << endl;
		return 0;
	}

	int dx[] = { 1, 2, -1, -2, 1, 2, -1, -2 }, dy[] = { 2, 1, 2, 1, -2, -1, -2, -1 };
	board[0][0][0] = true;
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 10; j++) {
			for(int k = 0; k < 10; k++) {
				for(int l = 0; l < 8; l++) {
					if(board[i][j][k]) {
						board[i + 1][j][k] = true;
						board[i + 1][i + dy[l]][j + dx[l]] = true;
					}
				}
			}
		}
	}
	cout << (board[3][y][x] ? "YES" : "NO") << endl;
}
0