提出 #19715


ソースコード 拡げる

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)

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[y][x]=-1.0;
    }

    U[sy][sx]=MAXN*MAXN+1;

    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;
            if(C[ny][nx]=='g'){ U[ny][nx]=max(U[ny][nx],U[y][x]); continue; }


            double s = (C[ny][nx]-'0')*pow(0.99,(double)t);
            if(U[ny][nx]>=s) continue; else U[ny][nx]=s;
            Q.push(pii(t+1,nx+ny*MAXN));
        }
    }

    if(U[gy][gx]<0.0) printf("-1\n"); else printf("%.10lf\n",U[gy][gx]);

    return 0;
}

提出情報

提出日時
問題 C - 暗闇帰り道
ユーザ mitsuchie
言語 C++ (G++ 4.6.4)
得点 0
コード長 1415 Byte
結果 WA
実行時間 165 ms
メモリ 3036 KB

ジャッジ結果

セット名 all
得点 / 配点 0 / 100
結果
AC × 22
WA × 42
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_mini_01.txt AC 23 ms 764 KB
00_mini_02.txt AC 20 ms 784 KB
00_mini_03.txt AC 23 ms 788 KB
00_mini_04.txt AC 22 ms 760 KB
00_mini_05.txt AC 23 ms 816 KB
00_sample_01.txt AC 21 ms 732 KB
00_sample_02.txt WA 21 ms 784 KB
01_rnd_01.txt WA 134 ms 2564 KB
01_rnd_02.txt WA 70 ms 2300 KB
01_rnd_03.txt WA 34 ms 1044 KB
01_rnd_04.txt WA 39 ms 1532 KB
01_rnd_05.txt WA 26 ms 1044 KB
01_rnd_06.txt WA 23 ms 916 KB
01_rnd_07.txt WA 34 ms 2564 KB
01_rnd_08.txt WA 75 ms 2808 KB
01_rnd_09.txt WA 98 ms 2556 KB
01_rnd_10.txt WA 81 ms 2672 KB
01_rnd_11.txt WA 59 ms 1812 KB
01_rnd_12.txt WA 46 ms 1656 KB
01_rnd_13.txt WA 25 ms 996 KB
01_rnd_14.txt WA 68 ms 2172 KB
01_rnd_15.txt WA 50 ms 1684 KB
01_rnd_16.txt WA 39 ms 1420 KB
01_rnd_17.txt AC 44 ms 1912 KB
01_rnd_18.txt AC 23 ms 1020 KB
01_rnd_19.txt AC 25 ms 2328 KB
01_rnd_20.txt AC 25 ms 2652 KB
02_maxrnd_01.txt WA 165 ms 3036 KB
02_maxrnd_02.txt WA 162 ms 3024 KB
02_maxrnd_03.txt WA 159 ms 2944 KB
02_maxrnd_04.txt WA 157 ms 2936 KB
02_maxrnd_05.txt WA 147 ms 2932 KB
02_maxrnd_06.txt WA 138 ms 2940 KB
02_maxrnd_07.txt WA 138 ms 2960 KB
02_maxrnd_08.txt WA 130 ms 2932 KB
02_maxrnd_09.txt WA 124 ms 2940 KB
02_maxrnd_10.txt WA 120 ms 2940 KB
02_maxrnd_11.txt WA 116 ms 2940 KB
02_maxrnd_12.txt WA 112 ms 2940 KB
02_maxrnd_13.txt WA 107 ms 2940 KB
02_maxrnd_14.txt WA 107 ms 2944 KB
02_maxrnd_15.txt WA 96 ms 2936 KB
02_maxrnd_16.txt WA 90 ms 2948 KB
02_maxrnd_17.txt AC 76 ms 2940 KB
02_maxrnd_18.txt AC 37 ms 2936 KB
02_maxrnd_19.txt AC 36 ms 2940 KB
03_hard_01.txt AC 160 ms 2944 KB
03_hard_02.txt WA 160 ms 2936 KB
03_hard_03.txt AC 81 ms 2948 KB
03_hard_04.txt AC 82 ms 2936 KB
03_hard_05.txt WA 163 ms 2936 KB
03_hard_06.txt WA 163 ms 2944 KB
03_hard_07.txt AC 82 ms 2940 KB
03_hard_08.txt AC 83 ms 2940 KB
04_open_01.txt AC 159 ms 2932 KB
04_open_02.txt WA 159 ms 2944 KB
05_minihard_01.txt WA 22 ms 832 KB
05_minihard_02.txt WA 22 ms 912 KB
05_minihard_03.txt AC 22 ms 912 KB
05_minihard_04.txt AC 24 ms 884 KB
05_minihard_05.txt WA 21 ms 892 KB
05_minihard_06.txt WA 22 ms 924 KB
05_minihard_07.txt WA 22 ms 892 KB
05_minihard_08.txt AC 22 ms 892 KB