結果

問題 No.240 ナイト散歩
ユーザー bal4ubal4u
提出日時 2019-04-15 20:49:55
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 792 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 30,436 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 06:46:52
合計ジャッジ時間 1,507 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.240 ナイト散歩
// 2019.4.15 bal4u

#include <stdio.h>

#define BASE 10
typedef struct { int x, y, s; } Q;
Q q[1000]; int top, end;
int mv[8][2] = {{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}};
char map[20][20];

int main()
{
	int i, x, y, s, xx, yy, ans;

	q[0].x = BASE, q[0].y = BASE, q[0].s = 0, top = 0, end = 1;
	while (top != end) {
		x = q[top].x, y = q[top].y, s = q[top++].s;
		if (map[x][y]) continue;
		map[x][y] = 1;
		if (s == 3) continue;
		for (i = 0; i < 8; i++) {
			xx = x + mv[i][0], yy = y + mv[i][1];
			if (!map[xx][yy]) q[end].x = xx, q[end].y = yy, q[end++].s = s + 1;
		}
	}
	scanf("%d%d", &x, &y);
	x += BASE, y += BASE;
	ans = 0;
	if (x >= 0 && y >= 0 && x <= 20 && y <= 20) ans = map[x][y];
	puts(ans ? "YES" : "NO");
	return 0;
}
0