Contest Duration: - (local time) (90 minutes) Back to Home

Submission #19612

Source Code Expand

Copy
```#include <iostream>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(n) REP(i,n)

#define INF 100000.0

const int dx[] = { 1, -1, 0, 0 };
const int dy[] = { 0, 0, -1, 1 };
const int MAXN=512;
char C[MAXN][MAXN];
double U[MAXN][MAXN];
int W,H;

typedef pair<int,int> pii;

int main()
{
cin>>H>>W; rep(H) cin>>C[i];

int sx,sy,gx,gy; REP(y,H) REP(x,W)
{
if( C[y][x] == 's' ){ sx=x; sy=y; C[y][x]='#'; }
if( C[y][x] == 'g' ){ gx=x; gy=y; }
}

U[sy][sx]=INF;

queue<pii> Q; Q.push(pii(1,sx+sy*MAXN)); while(!Q.empty())
{
const int t = Q.front().first;
const int x = Q.front().second%MAXN;
const int y = Q.front().second/MAXN;

Q.pop(); rep(4)
{
const int nx = x+dx[i];
const int ny = y+dy[i];
if(nx<0||ny<0||nx>=W||ny>=H) continue;
if(C[ny][nx]=='#') continue;

double s1 = (C[ny][nx]=='g'?INF:(C[ny][nx]-'0')*pow(0.99,t));
double s2 = min(s1,U[y][x]);

if(U[ny][nx]<s2){ U[ny][nx]=s2; if(C[ny][nx]!='g') Q.push(pii(t+1,nx+ny*MAXN)); }
}
}

if(abs(U[gy][gx])<(1e-9)) printf("-1\n"); else printf("%0.9f\n",U[gy][gx]);

return 0;
}
```

#### Submission Info

Submission Time 2012-05-27 22:25:39+0900 C - 暗闇帰り道 mitsuchie C++ (G++ 4.6.4) 0 1387 Byte WA 152 ms 3072 KB

#### Judge Result

Set Name all
Score / Max Score 0 / 100
Status
 AC × 60 WA × 4
Set Name Test Cases
all 00_mini_01.txt, 00_mini_02.txt, 00_mini_03.txt, 00_mini_04.txt, 00_mini_05.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 01_rnd_20.txt, 02_maxrnd_01.txt, 02_maxrnd_02.txt, 02_maxrnd_03.txt, 02_maxrnd_04.txt, 02_maxrnd_05.txt, 02_maxrnd_06.txt, 02_maxrnd_07.txt, 02_maxrnd_08.txt, 02_maxrnd_09.txt, 02_maxrnd_10.txt, 02_maxrnd_11.txt, 02_maxrnd_12.txt, 02_maxrnd_13.txt, 02_maxrnd_14.txt, 02_maxrnd_15.txt, 02_maxrnd_16.txt, 02_maxrnd_17.txt, 02_maxrnd_18.txt, 02_maxrnd_19.txt, 03_hard_01.txt, 03_hard_02.txt, 03_hard_03.txt, 03_hard_04.txt, 03_hard_05.txt, 03_hard_06.txt, 03_hard_07.txt, 03_hard_08.txt, 04_open_01.txt, 04_open_02.txt, 05_minihard_01.txt, 05_minihard_02.txt, 05_minihard_03.txt, 05_minihard_04.txt, 05_minihard_05.txt, 05_minihard_06.txt, 05_minihard_07.txt, 05_minihard_08.txt
Case Name Status Exec Time Memory
00_mini_01.txt AC 22 ms 792 KB
00_mini_02.txt AC 21 ms 780 KB
00_mini_03.txt AC 22 ms 760 KB
00_mini_04.txt AC 22 ms 764 KB
00_mini_05.txt AC 20 ms 748 KB
00_sample_01.txt AC 20 ms 780 KB
00_sample_02.txt AC 21 ms 788 KB
01_rnd_01.txt AC 107 ms 2636 KB
01_rnd_02.txt AC 64 ms 2272 KB
01_rnd_03.txt AC 37 ms 1040 KB
01_rnd_04.txt AC 41 ms 1532 KB
01_rnd_05.txt AC 26 ms 1020 KB
01_rnd_06.txt AC 23 ms 924 KB
01_rnd_07.txt AC 39 ms 2560 KB
01_rnd_08.txt AC 82 ms 2812 KB
01_rnd_09.txt AC 112 ms 2556 KB
01_rnd_10.txt AC 102 ms 2684 KB
01_rnd_11.txt AC 70 ms 1788 KB
01_rnd_12.txt AC 52 ms 1624 KB
01_rnd_13.txt AC 26 ms 916 KB
01_rnd_14.txt AC 70 ms 2168 KB
01_rnd_15.txt AC 45 ms 1660 KB
01_rnd_16.txt AC 34 ms 1400 KB
01_rnd_17.txt AC 36 ms 1908 KB
01_rnd_18.txt AC 22 ms 760 KB
01_rnd_19.txt AC 24 ms 920 KB
01_rnd_20.txt AC 22 ms 1044 KB
02_maxrnd_01.txt AC 132 ms 2940 KB
02_maxrnd_02.txt AC 136 ms 2940 KB
02_maxrnd_03.txt AC 145 ms 3068 KB
02_maxrnd_04.txt AC 141 ms 3072 KB
02_maxrnd_05.txt AC 149 ms 2940 KB
02_maxrnd_06.txt AC 147 ms 2940 KB
02_maxrnd_07.txt AC 145 ms 3068 KB
02_maxrnd_08.txt AC 152 ms 3020 KB
02_maxrnd_09.txt AC 150 ms 3072 KB
02_maxrnd_10.txt AC 151 ms 3064 KB
02_maxrnd_11.txt AC 147 ms 3064 KB
02_maxrnd_12.txt AC 135 ms 3064 KB
02_maxrnd_13.txt AC 124 ms 3064 KB
02_maxrnd_14.txt AC 108 ms 3044 KB
02_maxrnd_15.txt AC 89 ms 2932 KB
02_maxrnd_16.txt AC 72 ms 2928 KB
02_maxrnd_17.txt AC 61 ms 2936 KB
02_maxrnd_18.txt AC 34 ms 1404 KB
02_maxrnd_19.txt AC 34 ms 1276 KB
03_hard_01.txt AC 76 ms 2944 KB
03_hard_02.txt AC 77 ms 2940 KB
03_hard_03.txt WA 53 ms 2556 KB
03_hard_04.txt WA 55 ms 2928 KB
03_hard_05.txt AC 76 ms 3024 KB
03_hard_06.txt AC 77 ms 2936 KB
03_hard_07.txt WA 55 ms 2548 KB
03_hard_08.txt WA 57 ms 2960 KB
04_open_01.txt AC 63 ms 2944 KB
04_open_02.txt AC 127 ms 3060 KB
05_minihard_01.txt AC 21 ms 916 KB
05_minihard_02.txt AC 24 ms 888 KB
05_minihard_03.txt AC 23 ms 920 KB
05_minihard_04.txt AC 21 ms 916 KB
05_minihard_05.txt AC 21 ms 912 KB
05_minihard_06.txt AC 22 ms 892 KB
05_minihard_07.txt AC 20 ms 944 KB
05_minihard_08.txt AC 22 ms 916 KB