結果
問題 | No.157 2つの空洞 |
ユーザー |
|
提出日時 | 2017-08-10 10:33:34 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 447 bytes |
コンパイル時間 | 473 ms |
コンパイル使用メモリ | 30,976 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 03:53:38 |
合計ジャッジ時間 | 1,198 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
コンパイルメッセージ
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: warning: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] main.c:1:18: warning: 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: warning: 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: warning: 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: warning: 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: warning: 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: warning: 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: warning: type defaults to 'int' in declaration of 'w' [-Wimplicit-int] main.c:1:58: warning: 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,
ソースコード
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,0,0); } } main(){ for(scanf("%d%d\n",&w,&h);gets(m[i++]);); for(i=0;i<h;i++)for(j=0;j<w;j++)u[i][j]||m[i][j]-'.'||f(i,j,0,++a,0); 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); }