結果

問題 No.240 ナイト散歩
ユーザー fal_rnd
提出日時 2017-01-21 01:18:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 835 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 163,276 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 04:09:44
合計ジャッジ時間 3,486 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22 WA * 8
権限があれば一括ダウンロードができます

ソースコード

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,true);

	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;
	}

	return 0;
}
0