結果

問題 No.240 ナイト散歩
ユーザー ramia777ramia777
提出日時 2022-05-31 02:27:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,019 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 98,384 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 00:27:39
合計ジャッジ時間 1,973 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// yukicodr
//No.240



//二次元可変配列
//vector <vector <int>> mass;
//vector <vector <int>> memo;
//vector <int> memo;


//#include "stdafx.h"
#include <iostream>
#include <vector>
#include <list>//list
#include <queue> //queue
#include <set> //tree
#include <map> //連想配列
#include <unordered_set> //hash
#include <unordered_map> //hash
#include <algorithm>
#include <iomanip>
#include <cstring>
//#include <bits/stdc++.h>

using namespace std;

#define FOR(x,to) for(x=0;x<to;x++)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FMAX(a,b)  ((a)>(b)?(a):(b))
#define FMIN(a,b)  ((a)<(b)?(a):(b))
#define FCEIL(a,b)  ((a)+(b)-1)/(b)

typedef unsigned long long ULL;
typedef signed long long SLL;





//昇順
int compare_up(const int * a, const int *b)
{
	if (*a > *b)
		return (1);
	else if (*a < *b)
		return (-1);
	return (0);
}

//降順
int compare_down(const int * a, const int *b)
{
	if (*a > *b)
		return (-1);
	else if (*a < *b)
		return (1);
	return (0);
}

int solve(int i, ULL index_flag)
{

	return 0;
}

SLL dx[8] = { -2,-2,-1,-1, 1, 1, 2, 2 };
SLL dy[8] = { -1, 1,-2, 2,-2, 2,-1, 1 };


SLL X, Y;
typedef struct COORD {
	SLL x;
	SLL y;
}COORD;

queue<COORD> _queue;

COORD a;

SLL ban[25][25];

int main()
{
	SLL k = 0;

	cin >> X;
	cin >> Y;

	if (abs(X) >= 10 || abs(Y) >= 10)
	{
		cout << "NO" << endl;
		return 0;
	}

	a.x = 0;
	a.y = 0;
	ban[a.y + 10][a.x + 10] = 8;

	for (int j = 0; j <65; j++)
	{
		for (int i = 0; i < 8; i++)
		{
			COORD c;

			c.x =a.x+ dx[i];
			c.y =a.y+ dy[i];

			if(c.y ==0 && c.x == 0)
			ban[c.y + 10][c.x + 10] = 8;
			else
			ban[c.y + 10][c.x + 10] = 1;
			_queue.push(c); //キューに入れる
		}


		//先頭を見る
		a = _queue.front();

		//先頭を取り除く
		_queue.pop();
	}

	/*
	for (int y = 0;y<20;y++)
	{
		for (int x = 0; x < 20;x++)
			cout << ban[y][x];
		cout << endl;
	}
	*/

	if (ban[Y+10][X+10])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;


	//getchar();
	return 0;

}

0