結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
Bantako
|
| 提出日時 | 2017-07-09 18:21:55 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 406 bytes |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 22,400 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 21:39:50 |
| 合計ジャッジ時間 | 1,106 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
6 | main(){
| ^~~~
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d%d",&X,&Y);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
int X,Y;
int px[] = {-2,-2,-1,-1,1,1,2,2};
int py[] = {-1,1,-2,2,-2,2,-1,1};
int search(int nx,int ny,int i);
main(){
scanf("%d%d",&X,&Y);
printf("%s\n",search(0,0,3)?"YES":"NO");
}
int search(int nx,int ny,int i){
if(nx==X && ny==Y){return 1;}
if(i == 0){return 0;}
for(int j = 0;j < 8;j++){
if(search(nx+px[j],ny+py[j],i-1)){return 1;}
}
return 0;
}
Bantako