QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637038#8774. Manhattan WalkTenshi#WA 0ms3908kbC++231.3kb2024-10-13 06:37:402024-10-13 06:37:40

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 06:37:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3908kb
  • [2024-10-13 06:37:40]
  • 提交

answer

#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>

using namespace std;

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

#define ld long double

int main() {
    long long r, c; cin >> r >> c;
    ld p; cin >> p;
    ld ans[r][c];
    ld p4 = p*(ld)4;
    rep (ii, r) {
        rep (jj, c) {
            int i = r-ii-1;
            int j = c-jj-1;
            // cout << i << ' ' << j << endl;
            if (i==r-1 and j==c-1) {
                ans[i][j] = 0;
            }
            else if (i==r-1) {
                ans[i][j] = ans[i][j+1] + p/(ld)4;
            }
            else if (j==c-1) {
                ans[i][j] = ans[i+1][j] + p/(ld)4;
            }
            else {
                ld mn = ans[i+1][j];
                ld mx = ans[i+1][j];
                if (ans[i+1][j] < ans[i][j+1]) {
                    mx = ans[i][j+1];
                }
                else {
                    mn = ans[i][j+1];
                }
                ld d = mx-mn;
                ans[i][j] = mn/2.0 + mx/2.0 - (mn/p4)*d;
            }
            assert(ans[i][j] > -0.5);
        }
    }
    // rep(i, r) {
    //     rep(j, c) {
    //         cout << ans[i][j] << ' ';
    //     }
    //     cout << endl << endl;
    // }
    cout << fixed << setprecision(10) << ans[0][0] << endl;
}   

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3908kb

input:

2 3 8

output:

2.8750000000

result:

ok found '2.8750000', expected '2.8750000', error '0.0000000'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3900kb

input:

5 5 5

output:

2.3365097147

result:

wrong answer 1st numbers differ - expected: '2.4322339', found: '2.3365097', error = '0.0393565'