結果

問題 No.240 ナイト散歩
ユーザー evawenis
提出日時 2020-06-25 13:04:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 1,985 ms
コンパイル使用メモリ 193,644 KB
最終ジャッジ日時 2025-01-11 10:09:45
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int dx,dy;

bool trip(int x,int y,int c){
	if(c>3)return false;
	if(x==dx&&y==dy)return true;
	if(trip(x-2,y-1,c+1))return true;
	if(trip(x-2,y+1,c+1))return true;
	if(trip(x-1,y-2,c+1))return true;
	if(trip(x-1,y+2,c+1))return true;
	if(trip(x+1,y-2,c+1))return true;
	if(trip(x+1,y+2,c+1))return true;
	if(trip(x+2,y-1,c+1))return true;
	if(trip(x+2,y+1,c+1))return true;
	return false;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	cin>>dx>>dy;
	cout<<(trip(0,0,0)?"YES"s:"NO"s)<<"\n"s;
}
0