結果
問題 | No.659 徘徊迷路 |
ユーザー | tails |
提出日時 | 2018-03-02 23:40:54 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 1,336 bytes |
コンパイル時間 | 1,160 ms |
コンパイル使用メモリ | 32,768 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-22 13:44:57 |
合計ジャッジ時間 | 1,673 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 12 |
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class 1 | r;c;long long t; | ^ main.c:1:1: warning: type defaults to 'int' in declaration of 'r' [-Wimplicit-int] main.c:1:3: warning: data definition has no type or storage class 1 | r;c;long long t; | ^ main.c:1:3: warning: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] main.c:2:1: warning: data definition has no type or storage class 2 | sy;sx; | ^~ main.c:2:1: warning: type defaults to 'int' in declaration of 'sy' [-Wimplicit-int] main.c:2:4: warning: data definition has no type or storage class 2 | sy;sx; | ^~ main.c:2:4: warning: type defaults to 'int' in declaration of 'sx' [-Wimplicit-int] main.c:3:1: warning: data definition has no type or storage class 3 | gy;gx; | ^~ main.c:3:1: warning: type defaults to 'int' in declaration of 'gy' [-Wimplicit-int] main.c:3:4: warning: data definition has no type or storage class 3 | gy;gx; | ^~ main.c:3:4: warning: type defaults to 'int' in declaration of 'gx' [-Wimplicit-int] main.c:8:1: warning: data definition has no type or storage class 8 | y;x;v;u;j;i; | ^ main.c:8:1: warning: type defaults to 'int' in declaration of 'y' [-Wimplicit-int] main.c:8:3: warning: data definition has no type or storage class 8 | y;x;v;u;j;i; | ^ main.c:8:3: warning: type defaults to 'int' in declaration of 'x' [-Wimplicit-int] main.c:8:5: warning: data definition has no type or storage class 8 | y;x;v;u;j;i; | ^ main.c:8:5: warning: type defaults to 'int' in declaration of 'v' [-Wimplicit-int] main.c:8:7: warning: data definition has no type or storage class 8 | y;x;v;u;j;i; | ^ main.c:8:7: warning: type defaults to 'int' in declaration of 'u' [-Wimplicit-int] main.c:8:9: warning: data definition has no type or storage class 8 | y;x;v;u;j;i; | ^ main.c:8:9: warning: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
ソースコード
r;c;long long t; sy;sx; gy;gx; char b[12][12]; double m[12][12][12][12]; double n[12][12][12][12]; double e[12][12][12][12]; y;x;v;u;j;i; f(long long l){ if(l>1){ f(l>>1); memcpy(n,m,sizeof m); for(y=0;y<r;++y){ for(x=0;x<c;++x){ for(v=0;v<r;++v){ for(u=0;u<c;++u){ m[y][x][v][u]=0; for(j=0;j<r;++j){ for(i=0;i<c;++i){ m[y][x][v][u]+=n[y][x][j][i]*n[j][i][v][u]; } } } } } } } if(l&1){ memcpy(n,m,sizeof m); for(y=0;y<r;++y){ for(x=0;x<c;++x){ for(v=0;v<r;++v){ for(u=0;u<c;++u){ m[y][x][v][u]=0; for(j=0;j<r;++j){ for(i=0;i<c;++i){ m[y][x][v][u]+=n[y][x][j][i]*e[j][i][v][u]; } } } } } } } } main(){ scanf("%d%d%lld ",&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; if(b[y-1][x]=='.') ++k; if(b[y+1][x]=='.') ++k; if(b[y][x-1]=='.') ++k; if(b[y][x+1]=='.') ++k; if(k){ double p=1./k; if(b[y-1][x]=='.') e[y][x][y-1][x]=p; if(b[y+1][x]=='.') e[y][x][y+1][x]=p; if(b[y][x-1]=='.') e[y][x][y][x-1]=p; if(b[y][x+1]=='.') e[y][x][y][x+1]=p; }else{ e[y][x][y][x]=1; } m[y][x][y][x]=1; } } f(t); printf("%.9f\n",m[sy][sx][gy][gx]); }