結果

問題 No.157 2つの空洞
コンテスト
ユーザー kotatsugame
提出日時 2017-08-10 10:35:18
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 438 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 152 ms
コンパイル使用メモリ 28,428 KB
最終ジャッジ日時 2026-02-22 00:08:26
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:1:16: warning: data definition has no type or storage class
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
      |                ^
main.c:1:16: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:1:18: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
      |                  ^
main.c:1:20: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
      |                    ^
main.c:1:22: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int]
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
      |                      ^
main.c:1:24: warning: data definition has no type or storage class
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
      |                        ^
main.c:1:24: error: type defaults to 'int' in declaration of 'u' [-Wimplicit-int]
main.c:1:34: warning: data definition has no type or storage class
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
      |                                  ^
main.c:1:34: error: type defaults to 'int' in declaration of 'd' [-Wimplicit-int]
main.c:1:50: warning: data definition has no type or storage class
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
      |                                                  ^
main.c:1:50: error: type defaults to 'int' in declaration of 'M' [-Wimplicit-int]
main.c:1:56: warning: data definition has no type or storage class
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
      |                                                        ^
main.c:1:56: error: type defaults to 'int' in declaration of 'w' [-Wimplicit-int]
main.c:1:58: error: type defaults to 'int' in declaration of 'h' [-Wimplicit-int]
    1 | char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
   

ソースコード

diff #
raw source code

char m[30][30];i,j,a,b;u[30][30];d[5]={0,1,0,-1};M=1e9;w,h;
f(x,y,r,s,t){
	for(u[x][y]=a;r<4;){
		s=x+d[r];t=y+d[++r];
		if(s>=0&&t>=0&&s<h&&t<w&&!u[s][t]&&m[s][t]-'#')f(s,t,0);
	}
}
main(){
	for(scanf("%d%d\n",&w,&h);gets(m[j++]););
	for(;i<h;i++)for(j=0;j<w;j++)u[i][j]||m[i][j]-'.'||f(i,j,0,++a);
	for(i=0;i<h;i++)for(j=0;j<w;j++)for(a=0;a<h;a++)for(b=0;b<w;b++)u[i][j]+u[a][b]==3&&(M=fmin(M,fabs(i-a)+fabs(j-b)-1));
	printf("%d",M);
}
0