提出 #18943


ソースコード 拡げる

Copy
#include <queue>
#include <cctype>
#include <cstdio>
#include <algorithm>

using namespace std;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const int MAXN = 512;
char buf[MAXN][MAXN];
int tag[MAXN][MAXN];
double init[MAXN][MAXN];
double maxd[MAXN][MAXN];

int main() {
    int r, c, ts;
    double rate, ans;
    int sx = -1, sy = -1, tx = -1, ty = -1;
    vector<pair<pair<int, int>, double> > cur, pre;

    scanf("%d%d", &r, &c);
    for (int i = 1; i <= r; ++i) {
        scanf("%s", buf[i] + 1);
        for (int j = 1; j <= c; ++j) {
            if (buf[i][j] == 's') {
                sx = i;
                sy = j;
            } else if (isdigit(buf[i][j])) {
                init[i][j] = buf[i][j] - '0';
            }
        }
    }

    ts = 0;
    rate = 1.0;
    ans = 0.0;
    maxd[sx][sy] = 10.0;
    cur.push_back({{sx, sy}, maxd[sx][sy]});
    while (!cur.empty()) {
        ++ts;
        rate *= 0.99;
        pre.swap(cur);
        cur.clear();
        for (int i = 0; i < (int)pre.size(); ++i) {
            sx = pre[i].first.first;
            sy = pre[i].first.second;
            double sz = pre[i].second;
            // printf("[%d,%d,%d] %lf\n", sx, sy, ts, sz);
            for (int j = 0; j < 4; ++j) {
                tx = sx + dx[j];
                ty = sy + dy[j];
                if (buf[tx][ty] == 'g') {
                    ans = max(ans, sz);
                } else if (init[tx][ty] > 0) {
                    double tz = min(init[tx][ty] * rate, sz);
                    if (maxd[tx][ty] < tz) {
                        maxd[tx][ty] = tz;
                        if (tag[tx][ty] != ts) {
                            tag[tx][ty] = ts;
                            cur.push_back({{tx, ty}, 0.0});
                        }
                    }
                }
            }
        }
        for (int i = 0; i < (int)cur.size(); ++i) {
            cur[i].second = maxd[cur[i].first.first][cur[i].first.second];
        }
    }
    printf("%.10lf\n", ans);

    return 0;
}

提出情報

提出日時
問題 C - 暗闇帰り道
ユーザ watashi
言語 C++11 (GCC 4.8.1)
得点 0
コード長 2113 Byte
結果 WA
実行時間 102 ms
メモリ 6244 KB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:23:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:25:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

ジャッジ結果

セット名 all
得点 / 配点 0 / 100
結果
AC × 57
WA × 7
セット名 テストケース
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 24 ms 784 KB
00_mini_02.txt AC 24 ms 780 KB
00_mini_03.txt AC 26 ms 776 KB
00_mini_04.txt AC 25 ms 908 KB
00_mini_05.txt WA 26 ms 784 KB
00_sample_01.txt AC 24 ms 780 KB
00_sample_02.txt AC 26 ms 780 KB
01_rnd_01.txt AC 64 ms 5200 KB
01_rnd_02.txt AC 51 ms 4488 KB
01_rnd_03.txt AC 30 ms 1532 KB
01_rnd_04.txt AC 33 ms 2680 KB
01_rnd_05.txt AC 27 ms 1420 KB
01_rnd_06.txt AC 25 ms 1164 KB
01_rnd_07.txt AC 42 ms 5160 KB
01_rnd_08.txt AC 60 ms 5632 KB
01_rnd_09.txt AC 76 ms 5124 KB
01_rnd_10.txt AC 72 ms 5460 KB
01_rnd_11.txt AC 52 ms 3328 KB
01_rnd_12.txt AC 43 ms 3056 KB
01_rnd_13.txt AC 26 ms 1152 KB
01_rnd_14.txt AC 55 ms 4312 KB
01_rnd_15.txt AC 42 ms 2948 KB
01_rnd_16.txt AC 31 ms 2308 KB
01_rnd_17.txt WA 36 ms 3656 KB
01_rnd_18.txt WA 23 ms 1120 KB
01_rnd_19.txt WA 24 ms 2316 KB
01_rnd_20.txt WA 25 ms 2684 KB
02_maxrnd_01.txt AC 67 ms 6216 KB
02_maxrnd_02.txt AC 79 ms 6144 KB
02_maxrnd_03.txt AC 80 ms 6244 KB
02_maxrnd_04.txt AC 83 ms 6140 KB
02_maxrnd_05.txt AC 92 ms 6152 KB
02_maxrnd_06.txt AC 90 ms 6020 KB
02_maxrnd_07.txt AC 90 ms 6140 KB
02_maxrnd_08.txt AC 94 ms 6140 KB
02_maxrnd_09.txt AC 102 ms 6140 KB
02_maxrnd_10.txt AC 101 ms 6228 KB
02_maxrnd_11.txt AC 92 ms 6140 KB
02_maxrnd_12.txt AC 91 ms 6220 KB
02_maxrnd_13.txt AC 89 ms 6140 KB
02_maxrnd_14.txt AC 78 ms 6152 KB
02_maxrnd_15.txt AC 66 ms 6020 KB
02_maxrnd_16.txt AC 58 ms 6012 KB
02_maxrnd_17.txt AC 53 ms 6016 KB
02_maxrnd_18.txt WA 31 ms 3596 KB
02_maxrnd_19.txt WA 31 ms 3452 KB
03_hard_01.txt AC 45 ms 6016 KB
03_hard_02.txt AC 49 ms 6020 KB
03_hard_03.txt AC 70 ms 6016 KB
03_hard_04.txt AC 71 ms 6016 KB
03_hard_05.txt AC 47 ms 6020 KB
03_hard_06.txt AC 47 ms 5960 KB
03_hard_07.txt AC 64 ms 6020 KB
03_hard_08.txt AC 70 ms 6020 KB
04_open_01.txt AC 46 ms 6016 KB
04_open_02.txt AC 67 ms 6012 KB
05_minihard_01.txt AC 21 ms 1040 KB
05_minihard_02.txt AC 25 ms 1036 KB
05_minihard_03.txt AC 24 ms 1036 KB
05_minihard_04.txt AC 22 ms 1120 KB
05_minihard_05.txt AC 27 ms 1100 KB
05_minihard_06.txt AC 25 ms 1036 KB
05_minihard_07.txt AC 26 ms 1092 KB
05_minihard_08.txt AC 25 ms 1024 KB