結果

問題 No.424 立体迷路
ユーザー tailstails
提出日時 2016-09-23 00:13:15
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 20,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 07:07:16
合計ジャッジ時間 876 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 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 0 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 0 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 0 ms
5,376 KB
testcase_17 AC 0 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 0 ms
5,376 KB
testcase_20 AC 0 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 0 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | h;w;a;b;
      | ^
main.c:1:1: warning: type defaults to ‘int’ in declaration of ‘h’ [-Wimplicit-int]
main.c:1:3: warning: data definition has no type or storage class
    1 | h;w;a;b;
      |   ^
main.c:1:3: warning: type defaults to ‘int’ in declaration of ‘w’ [-Wimplicit-int]
main.c:1:5: warning: data definition has no type or storage class
    1 | h;w;a;b;
      |     ^
main.c:1:5: warning: type defaults to ‘int’ in declaration of ‘a’ [-Wimplicit-int]
main.c:1:7: warning: data definition has no type or storage class
    1 | h;w;a;b;
      |       ^
main.c:1:7: warning: type defaults to ‘int’ in declaration of ‘b’ [-Wimplicit-int]
main.c:4:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    4 | f(x,y){
      | ^
main.c: In function ‘f’:
main.c:4:1: warning: type of ‘x’ defaults to ‘int’ [-Wimplicit-int]
main.c:4:1: warning: type of ‘y’ defaults to ‘int’ [-Wimplicit-int]
main.c:8:27: warning: implicit declaration of function ‘abs’ [-Wimplicit-function-declaration]
    8 |                 if(x>0  &&abs(m[x][y]-m[x-1][y])<2)f(x-1,y);
      |                           ^~~
main.c:1:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘abs’
  +++ |+#include <stdlib.h>
    1 | h;w;a;b;
main.c: At top level:
main.c:18:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   18 | main(x,y,i){
      | ^~~~
main.c: In function ‘main’:
main.c:18:1: warning: type of ‘x’ defaults to ‘int’ [-Wimplicit-int]
main.c:18:1: warning: type of ‘y’ defaults to ‘int’ [-Wimplicit-int]
main.c:18:1: warning: type of ‘i’ defaults to ‘int’ [-Wimplicit-int]
main.c:19:9: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
   19 |         scanf("%d%d%d%d%d%d ",&h,&w,&x,&y,&a,&b);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration o

ソースコード

diff #

h;w;a;b;
char m[60][60],u[60][60];
char*r="NO";
f(x,y){
	if(!u[y][x]){
		u[y][x]=1;
		if(x==a&&y==b)r="YES";
		if(x>0  &&abs(m[x][y]-m[x-1][y])<2)f(x-1,y);
		if(x<h-1&&abs(m[x][y]-m[x+1][y])<2)f(x+1,y);
		if(y>0  &&abs(m[x][y]-m[x][y-1])<2)f(x,y-1);
		if(y<w-1&&abs(m[x][y]-m[x][y+1])<2)f(x,y+1);
		if(x>1  &&m[x][y]==m[x-2][y]&&m[x][y]>m[x-1][y])f(x-2,y);
		if(x<h-2&&m[x][y]==m[x+2][y]&&m[x][y]>m[x+1][y])f(x+2,y);
		if(y>1  &&m[x][y]==m[x][y-2]&&m[x][y]>m[x][y-1])f(x,y-2);
		if(y<w-2&&m[x][y]==m[x][y+2]&&m[x][y]>m[x][y+1])f(x,y+2);
	}
}
main(x,y,i){
	scanf("%d%d%d%d%d%d ",&h,&w,&x,&y,&a,&b);
	for(i=0;i<h;++i)gets(m[i]);
	--x;--y;--a;--b;
	f(x,y);
	puts(r);
	exit(0);
}
0