結果

問題 No.240 ナイト散歩
ユーザー horiesiniti
提出日時 2016-07-17 18:39:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 55,624 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-07 21:27:21
合計ジャッジ時間 1,508 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |         scanf("%d %d",&X,&Y);
      |         ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include<stdlib.h>
#include<stdio.h>
int ds[4]={-2,-1,1,2};
bool hit=false;
int X,Y;
void f(int deep,int x,int y){
	if(deep==4){
		return ;
	}else{
		if((x==X)&&(y==Y)){
			hit=true;
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(abs(ds[i])+abs(ds[j])==3){
					f(deep+1,x+ds[i],y+ds[j]);
				}
			}
		}
	}
}

int main() {
	scanf("%d %d",&X,&Y);
	f(0,0,0);
	printf("%s\n",hit?"YES":"NO");
	return 0;
}
0