結果

問題 No.240 ナイト散歩
ユーザー suppy193suppy193
提出日時 2015-07-13 15:54:37
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,279 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 19:31:18
合計ジャッジ時間 1,018 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 0 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 0 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 0 ms
5,376 KB
testcase_16 AC 0 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 0 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 0 ms
5,376 KB
testcase_21 AC 0 ms
5,376 KB
testcase_22 AC 0 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 0 ms
5,376 KB
testcase_25 AC 0 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 0 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 0 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |         ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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