結果

問題 No.240 ナイト散歩
ユーザー fal_rndfal_rnd
提出日時 2017-01-21 01:23:14
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 942 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 163,456 KB
実行使用メモリ 6,816 KB
最終ジャッジ日時 2024-04-16 19:45:35
合計ジャッジ時間 2,131 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using  ll = long long int;
using ull = unsigned long long int;
const char en ='\n';
const int  mod=1000000007;

int main(){
	cin.tie();
	ios::sync_with_stdio(false);

	bool field[20][20]; for(int i=0;i<20;i++) fill_n(field[i],20,false);

	int dx[]{-2,-2,-1,-1,1,1,2,2};
	int dy[]{-1,1,-2,2,-2,2,-1,1};


	deque<pair<int,int>> d;
	d.push_back(make_pair(10,10));
	field[10][10]=true;
	for(int i=0;i<3;i++){
		int size=d.size();
		for(int j=0;j<size;j++){
			pair<int,int> p=d.front(),q;
			d.pop_front();
			for(int k=0;k<8;k++){
				q=make_pair(p.first+dx[k],p.second+dy[k]);
				d.push_back(q);
				field[q.first][q.second]=true;
			}
		}
	}

	int x,y;
	cin>>x>>y;

	x+=10;
	y+=10;

	if(x>20||x<0||y>20||y<0){
		cout<<"NO"<<en;
	}else{
		cout<<(field[x][y]?"YES":"NO")<<en;
	}

	/*
	for(int i=0;i<20;i++){
		for(int j=0;j<20;j++){
			cout<<field[i][j]<<" ";
		}
		cout<<en;
	}
	*/

	return 0;
}
0