結果

問題 No.659 徘徊迷路
コンテスト
ユーザー 👑 tails
提出日時 2018-03-03 00:14:43
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 926 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 131 ms
コンパイル使用メモリ 33,436 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-08 16:16:09
合計ジャッジ時間 1,264 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 5
other RE * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | r;c;t;
      | ^
main.c:1:3: warning: data definition has no type or storage class
    1 | r;c;t;
      |   ^
main.c:1:5: warning: data definition has no type or storage class
    1 | r;c;t;
      |     ^
main.c:2:1: warning: data definition has no type or storage class
    2 | sy;sx;
      | ^~
main.c:2:4: warning: data definition has no type or storage class
    2 | sy;sx;
      |    ^~
main.c:3:1: warning: data definition has no type or storage class
    3 | gy;gx;
      | ^~
main.c:3:4: warning: data definition has no type or storage class
    3 | gy;gx;
      |    ^~
main.c:7:1: warning: data definition has no type or storage class
    7 | y;x;v;u;j;i;
      | ^
main.c:7:3: warning: data definition has no type or storage class
    7 | y;x;v;u;j;i;
      |   ^
main.c:7:5: warning: data definition has no type or storage class
    7 | y;x;v;u;j;i;
      |     ^
main.c:7:7: warning: data definition has no type or storage class
    7 | y;x;v;u;j;i;
      |       ^
main.c:7:9: warning: data definition has no type or storage class
    7 | y;x;v;u;j;i;
      |         ^
main.c:7:11: warning: data definition has no type or storage class
    7 | y;x;v;u;j;i;
      |           ^
main.c: In function ‘mul’:
main.c:10:9: warning: incompatible implicit declaration of built-in function ‘memcpy’ [-Wbuiltin-declaration-mismatch]
   10 |         memcpy(n,m,sizeof n);
      |         ^~~~~~
main.c:1:1: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’
  +++ |+#include <string.h>
    1 | r;c;t;
main.c: In function ‘main’:
main.c:32:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   32 |         scanf("%d%d%d ",&r,&c,&t);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | r;c;t;
main.c:60:9: warning: incompatible implicit decla

ソースコード

diff #
raw source code

r;c;t;
sy;sx;
gy;gx;
char b[10][12];
typedef double mtx[100][100];
mtx m,n,e;
y;x;v;u;j;i;

mul(mtx a){
	memcpy(n,m,sizeof n);
	for(y=0;y<100;++y){
		for(v=0;v<100;++v){
			m[y][v]=0;
			for(j=0;j<100;++j){
				m[y][v]+=n[y][j]*a[j][v];
			}
		}
	}
}

f(l){
	if(l>1){
		f(l>>1);
		mul(n);
	}
	if(l&1){
		mul(e);
	}
}

main(){
	scanf("%d%d%d ",&r,&c,&t);
	scanf("%d%d ",&sy,&sx);
	scanf("%d%d ",&gy,&gx);
	for(y=0;y<r;++y){
		gets(b[y]);
	}

	for(y=1;y<r-1;++y){
		for(x=1;x<c-1;++x){
			int k=0;
			k+=b[y-1][x]=='.';
			k+=b[y+1][x]=='.';
			k+=b[y][x-1]=='.';
			k+=b[y][x+1]=='.';
			if(k){
				double p=1./k;
				if(b[y-1][x]=='.') e[y*10+x][(y-1)*10+x]=p;
				if(b[y+1][x]=='.') e[y*10+x][(y+1)*10+x]=p;
				if(b[y][x-1]=='.') e[y*10+x][y*10+(x-1)]=p;
				if(b[y][x+1]=='.') e[y*10+x][y*10+(x+1)]=p;
			}else{
				e[y*10+x][y*10+x]=1;
			}
			m[y*10+x][y*10+x]=1;
		}
	}

	f(t);
	printf("%.9f\n",m[sy*10+sx][gy*10+gx]);
}
0