結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2015-07-13 15:54:37 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,279 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 21,504 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-07 20:57:10 |
合計ジャッジ時間 | 1,029 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.c: In function ‘dfs’: main.c:3:5: warning: type of ‘x0’ defaults to ‘int’ [-Wimplicit-int] 3 | int dfs(x0, y0, x, y, n) | ^~~ main.c:3:5: warning: type of ‘y0’ defaults to ‘int’ [-Wimplicit-int] main.c:3:5: warning: type of ‘x’ defaults to ‘int’ [-Wimplicit-int] main.c:3:5: warning: type of ‘y’ defaults to ‘int’ [-Wimplicit-int] main.c:3:5: warning: type of ‘n’ defaults to ‘int’ [-Wimplicit-int] main.c: In function ‘main’: main.c:76:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 76 | scanf("%d%d", &x, &y); | ^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int dfs(x0, y0, x, y, n) { //printf("%d,%d\n", x0, y0); if(n <= 0){ return 0; } if(x0 == x && y0 == y){ return 1; } if(x0 - 2 == x && y0 - 1 == y){ return 1; } else if(dfs(x0 - 2, y0 - 1, x, y, n - 1) == 1){ return 1; } if(x0 - 2 == x && y0 + 1 == y){ return 1; } else if(dfs(x0 - 2, y0 + 1, x, y, n - 1) == 1){ return 1; } if(x0 - 1 == x && y0 - 2 == y){ return 1; } else if(dfs(x0 - 1, y0 - 2, x, y, n - 1) == 1){ return 1; } if(x0 - 1 == x && y0 + 2 == y){ return 1; } else if(dfs(x0 - 1, y0 + 2, x, y, n - 1) == 1){ return 1; } if(x0 + 1 == x && y0 - 2 == y){ return 1; } else if(dfs(x0 + 1, y0 - 2, x, y, n - 1) == 1){ return 1; } if(x0 + 1 == x && y0 + 2 == y){ return 1; } else if(dfs(x0 + 1, y0 + 2, x, y, n - 1) == 1){ return 1; } if(x0 + 2 == x && y0 - 1 == y){ return 1; } else if(dfs(x0 + 2, y0 - 1, x, y, n - 1) == 1){ return 1; } if(x0 + 2 == x && y0 + 1 == y){ return 1; } else if(dfs(x0 + 2, y0 + 1, x, y, n - 1) == 1){ return 1; } //,(x+2,y-1),(x+2,y+1) } int main(void) { int x, y; int x0, y0; scanf("%d%d", &x, &y); x0 = 0; y0 = 0; if(dfs(x0, y0, x, y, 3) == 1){ printf("YES\n"); } else{ printf("NO\n"); } return 0; }