QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637037#8774. Manhattan WalkTenshi#Compile Error//C++231.3kb2024-10-13 06:36:212024-10-13 06:36:21

Judging History

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

  • [2024-10-13 06:36:21]
  • 评测
  • [2024-10-13 06:36:21]
  • 提交

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

answer.code: In function ‘int main()’:
answer.code:42:13: error: ‘assert’ was not declared in this scope
   42 |             assert(ans[i][j] > -0.5);
      |             ^~~~~~
answer.code:4:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’?
    3 | #include <iomanip>
  +++ |+#include <cassert>
    4 |